From 35755f9b4d39ad2ed759cab9c7555c929eded31b Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Thu, 31 Jul 2025 09:50:42 +0700
Subject: [PATCH 1/5] fix empty report displayed after splitting track expense
 and deleting report

---
 src/libs/actions/IOU.ts | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index 193a4c4aba4b..07eee99f7cca 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -12202,6 +12202,29 @@ function saveSplitTransactions(draftTransaction: OnyxEntry<OnyxTypes.Transaction
         Navigation.dismissModal();
         return;
     }
+
+    const trackReport = Navigation.getReportRouteByID(draftTransaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID));
+
+    if (trackReport) {
+        Navigation.dismissModal();
+
+        InteractionManager.runAfterInteractions(() => {
+            Navigation.popToTop();
+
+            const backToRoute = trackReport.params && typeof trackReport.params === 'object' && 'backTo' in trackReport.params ? (trackReport.params.backTo as Route) : undefined;
+
+            if (backToRoute) {
+                Navigation.goBack(backToRoute);
+            }
+
+            requestAnimationFrame(() => {
+                Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(expenseReport?.reportID));
+            });
+        });
+
+        return;
+    }
+
     Navigation.dismissModalWithReport({reportID: expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)});
 }
 

From 8f97e396464a0d259f15c4ed7eafa09706f22c35 Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Thu, 31 Jul 2025 10:07:47 +0700
Subject: [PATCH 2/5] fix empty report after split and delete report

---
 src/components/MoneyReportHeader.tsx |  9 +++++++++
 src/libs/actions/IOU.ts              | 29 +++++++++++-----------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx
index f74a26af9cc2..162f3e8c82e9 100644
--- a/src/components/MoneyReportHeader.tsx
+++ b/src/components/MoneyReportHeader.tsx
@@ -71,6 +71,7 @@ import {
     cancelPayment,
     canIOUBePaid as canIOUBePaidAction,
     deleteMoneyRequest,
+    getNavigationUrlOnAppReportDelete,
     getNavigationUrlOnMoneyRequestDelete,
     initSplitExpense,
     payInvoice,
@@ -1177,6 +1178,14 @@ function MoneyReportHeader({
                     Navigation.goBack();
                     InteractionManager.runAfterInteractions(() => {
                         deleteAppReport(moneyRequestReport?.reportID);
+
+                        if (moneyRequestReport?.reportID && moneyRequestReport?.chatReportID) {
+                            const goBackRoute = getNavigationUrlOnAppReportDelete(moneyRequestReport.reportID, moneyRequestReport.chatReportID);
+
+                            if (goBackRoute) {
+                                Navigation.setNavigationActionToMicrotaskQueue(() => navigateOnDeleteExpense(goBackRoute));
+                            }
+                        }
                     });
                 }}
                 onCancel={() => setIsDeleteReportModalVisible(false)}
diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index 07eee99f7cca..d3639473f671 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -12203,29 +12203,21 @@ function saveSplitTransactions(draftTransaction: OnyxEntry<OnyxTypes.Transaction
         return;
     }
 
-    const trackReport = Navigation.getReportRouteByID(draftTransaction?.reportID ?? String(CONST.DEFAULT_NUMBER_ID));
-
-    if (trackReport) {
-        Navigation.dismissModal();
-
-        InteractionManager.runAfterInteractions(() => {
-            Navigation.popToTop();
-
-            const backToRoute = trackReport.params && typeof trackReport.params === 'object' && 'backTo' in trackReport.params ? (trackReport.params.backTo as Route) : undefined;
+    Navigation.dismissModalWithReport({reportID: expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)});
+}
 
-            if (backToRoute) {
-                Navigation.goBack(backToRoute);
-            }
+function getNavigationUrlOnAppReportDelete(reportID: string | undefined, chatReportID: string | undefined): Route | undefined {
+    if (!reportID || !chatReportID) {
+        return undefined;
+    }
 
-            requestAnimationFrame(() => {
-                Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(expenseReport?.reportID));
-            });
-        });
+    const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`];
 
-        return;
+    if (chatReport?.reportID) {
+        return ROUTES.REPORT_WITH_ID.getRoute(chatReport.reportID);
     }
 
-    Navigation.dismissModalWithReport({reportID: expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)});
+    return undefined;
 }
 
 export {
@@ -12334,5 +12326,6 @@ export {
     reopenReport,
     retractReport,
     startDistanceRequest,
+    getNavigationUrlOnAppReportDelete,
 };
 export type {GPSPoint as GpsPoint, IOURequestType, StartSplitBilActionParams, CreateTrackExpenseParams, RequestMoneyInformation, ReplaceReceipt};

From 7cc9ac3b0a1c150b1bb8a4ed1e584dda1d7f5f6a Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Thu, 31 Jul 2025 13:52:27 +0700
Subject: [PATCH 3/5] Remove screen of split report after the report is deleted

---
 src/components/MoneyReportHeader.tsx |  9 ---------
 src/libs/actions/IOU.ts              | 22 ++++++++--------------
 2 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx
index 162f3e8c82e9..f74a26af9cc2 100644
--- a/src/components/MoneyReportHeader.tsx
+++ b/src/components/MoneyReportHeader.tsx
@@ -71,7 +71,6 @@ import {
     cancelPayment,
     canIOUBePaid as canIOUBePaidAction,
     deleteMoneyRequest,
-    getNavigationUrlOnAppReportDelete,
     getNavigationUrlOnMoneyRequestDelete,
     initSplitExpense,
     payInvoice,
@@ -1178,14 +1177,6 @@ function MoneyReportHeader({
                     Navigation.goBack();
                     InteractionManager.runAfterInteractions(() => {
                         deleteAppReport(moneyRequestReport?.reportID);
-
-                        if (moneyRequestReport?.reportID && moneyRequestReport?.chatReportID) {
-                            const goBackRoute = getNavigationUrlOnAppReportDelete(moneyRequestReport.reportID, moneyRequestReport.chatReportID);
-
-                            if (goBackRoute) {
-                                Navigation.setNavigationActionToMicrotaskQueue(() => navigateOnDeleteExpense(goBackRoute));
-                            }
-                        }
                     });
                 }}
                 onCancel={() => setIsDeleteReportModalVisible(false)}
diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index d3639473f671..817c32e6ded3 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -12204,20 +12204,15 @@ function saveSplitTransactions(draftTransaction: OnyxEntry<OnyxTypes.Transaction
     }
 
     Navigation.dismissModalWithReport({reportID: expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)});
-}
-
-function getNavigationUrlOnAppReportDelete(reportID: string | undefined, chatReportID: string | undefined): Route | undefined {
-    if (!reportID || !chatReportID) {
-        return undefined;
-    }
-
-    const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`];
-
-    if (chatReport?.reportID) {
-        return ROUTES.REPORT_WITH_ID.getRoute(chatReport.reportID);
-    }
+    const transactionThreadReportID = iouActions.at(0)?.childReportID;
+    const trackTransactionThreadReport = Navigation.getReportRouteByID(transactionThreadReportID);
+    InteractionManager.runAfterInteractions(() => {
+        if (!trackTransactionThreadReport?.key) {
+            return;
+        }
 
-    return undefined;
+        Navigation.removeScreenByKey(trackTransactionThreadReport.key);
+    });
 }
 
 export {
@@ -12326,6 +12321,5 @@ export {
     reopenReport,
     retractReport,
     startDistanceRequest,
-    getNavigationUrlOnAppReportDelete,
 };
 export type {GPSPoint as GpsPoint, IOURequestType, StartSplitBilActionParams, CreateTrackExpenseParams, RequestMoneyInformation, ReplaceReceipt};

From bd9c543aeddbb67cd59d95bb7a7ae6cee9ad54ff Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Thu, 31 Jul 2025 13:54:42 +0700
Subject: [PATCH 4/5] remove breakline

---
 src/libs/actions/IOU.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index 817c32e6ded3..c940bbda57ab 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -12202,8 +12202,8 @@ function saveSplitTransactions(draftTransaction: OnyxEntry<OnyxTypes.Transaction
         Navigation.dismissModal();
         return;
     }
-
     Navigation.dismissModalWithReport({reportID: expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)});
+
     const transactionThreadReportID = iouActions.at(0)?.childReportID;
     const trackTransactionThreadReport = Navigation.getReportRouteByID(transactionThreadReportID);
     InteractionManager.runAfterInteractions(() => {

From d77acbdc05cccccfd502780ef655272e83944325 Mon Sep 17 00:00:00 2001
From: Huu Le <20178761+huult@users.noreply.github.com>
Date: Thu, 31 Jul 2025 15:02:05 +0700
Subject: [PATCH 5/5] Add comment to explain why the screen is removed

---
 src/libs/actions/IOU.ts | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index c940bbda57ab..9f322fef0f38 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -12197,21 +12197,36 @@ function saveSplitTransactions(draftTransaction: OnyxEntry<OnyxTypes.Transaction
 
     API.write(WRITE_COMMANDS.SPLIT_TRANSACTION, parameters, {optimisticData, successData, failureData});
     InteractionManager.runAfterInteractions(() => removeDraftSplitTransaction(originalTransactionID));
+
     const isSearchPageTopmostFullScreenRoute = isSearchTopmostFullScreenRoute();
+    const transactionThreadReportID = iouActions.at(0)?.childReportID;
+    const transactionThreadReportScreen = Navigation.getReportRouteByID(transactionThreadReportID);
+
     if (isSearchPageTopmostFullScreenRoute || !transactionReport?.parentReportID) {
         Navigation.dismissModal();
+
+        // After the modal is dismissed, remove the transaction thread report screen
+        // to avoid navigating back to a report removed by the split transaction.
+        requestAnimationFrame(() => {
+            if (!transactionThreadReportScreen?.key) {
+                return;
+            }
+
+            Navigation.removeScreenByKey(transactionThreadReportScreen.key);
+        });
+
         return;
     }
     Navigation.dismissModalWithReport({reportID: expenseReport?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)});
 
-    const transactionThreadReportID = iouActions.at(0)?.childReportID;
-    const trackTransactionThreadReport = Navigation.getReportRouteByID(transactionThreadReportID);
-    InteractionManager.runAfterInteractions(() => {
-        if (!trackTransactionThreadReport?.key) {
+    // After the modal is dismissed, remove the transaction thread report screen
+    // to avoid navigating back to a report removed by the split transaction.
+    requestAnimationFrame(() => {
+        if (!transactionThreadReportScreen?.key) {
             return;
         }
 
-        Navigation.removeScreenByKey(trackTransactionThreadReport.key);
+        Navigation.removeScreenByKey(transactionThreadReportScreen.key);
     });
 }
 
