diff --git a/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php b/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php
index 4e47343c3d994..350a47b8facde 100644
--- a/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php
+++ b/vendor/magento/module-sales/Controller/Adminhtml/Order/AddComment.php
@@ -6,7 +6,7 @@
 namespace Magento\Sales\Controller\Adminhtml\Order;

 use Magento\Framework\App\Action\HttpPostActionInterface;
-use Magento\Sales\Model\Order;
+use Magento\Sales\Api\Data\OrderInterface;
 use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;

 /**
@@ -45,7 +45,7 @@ public function execute()
                     throw new \Magento\Framework\Exception\LocalizedException(__($error));
                 }

-                $orderStatus = $this->getOrderStatus($order->getDataByKey('status'), $data['status']);
+                $orderStatus = $this->getOrderStatus($order, $data['status']);
                 $order->setStatus($orderStatus);
                 $notify = $data['is_customer_notified'] ?? false;
                 $visible = $data['is_visible_on_front'] ?? false;
@@ -85,13 +85,21 @@ public function execute()
     /**
      * Get order status to set
      *
-     * @param string $orderStatus
+     * @param OrderInterface $order
      * @param string $historyStatus
      * @return string
      */
-    private function getOrderStatus(string $orderStatus, string $historyStatus): string
+    private function getOrderStatus(OrderInterface $order, string $historyStatus): string
     {
-        return ($orderStatus === Order::STATE_PROCESSING || $orderStatus === Order::STATUS_FRAUD) ? $historyStatus
-            : $orderStatus;
+        $config = $order->getConfig();
+        if ($config === null) {
+            return $historyStatus;
+        }
+        $statuses = $config->getStateStatuses($order->getState());
+
+        if (!isset($statuses[$historyStatus])) {
+            return $order->getDataByKey('status');
+        }
+        return $historyStatus;
     }
 }
