diff --git a/scripts/update_submodule.py b/scripts/update_submodule.py
index 4e047c8144167facc198bc990a5286c681387d1a..9561d916dabc26cd238182dd86ca7819ea91bd76 100755
--- a/scripts/update_submodule.py
+++ b/scripts/update_submodule.py
@@ -298,13 +298,9 @@ def update_submodule_and_include_ref(
             logging.debug("Head of %s points to %s", branch, integration_base_id)
 
             # Loop over the commits until the integration_branch head id is found
-            if not common.is_commit_parent_of_project_commit(
+            if common.is_commit_parent_of_project_commit(
                 project, existing_branch.commit["id"], integration_base_id, limit=5
             ):
-                logging.debug("Integration branch is outdated, delete it.")
-                project.branches.delete(existing_branch.name)
-                existing_branch = None
-            else:
                 # Check the submodule revision on the integration branch
                 (
                     _,
@@ -325,6 +321,10 @@ def update_submodule_and_include_ref(
                     )
                     integration_commit = existing_branch.commit["id"]
                     submodule_update_needed = False
+            else:
+                logging.debug("Integration branch is outdated, delete it.")
+                project.branches.delete(existing_branch.name)
+                existing_branch = None
 
     # Clone the project, we need to do changes
     if submodule_update_needed or force_clone: