code: protected function fixCustomers(OrderInterface $order)
      {
          $changed = false;
  
          $originCustomer = $order->getOriginCustomer();
          $customer = $order->getCustomer();
  
          if (is_null($customer)) {
              if ($originCustomer && $originCustomer->hasParent()) {
                  $order->setCustomer($originCustomer->getParent());
  
                  $changed = true;
              }
          } elseif ($customer->hasParent()) {
              $order->setCustomer($customer->getParent());
  
              if (null === $order->getOriginCustomer()) {
                  $order->setOriginCustomer($customer);
              }
  
              $changed = true;
          }
  
          if ($changed) {
              $this->persistenceHelper->persistAndRecompute($order, false);
          }
  
          return $changed;
      }
docs: Changes the customer and origin customer regarding to their hierarchy.
  
  @param OrderInterface $order
  
  @return bool