From a8b556e92998488bad4617278ee814906de6fd6e Mon Sep 17 00:00:00 2001 From: MobileMage Date: Fri, 12 Jun 2026 03:14:46 +0100 Subject: [PATCH 1/3] Fix Review Duplicates merge navigation from Search and on browser back handleMergeDuplicates branched on getTopmostReportId, which only inspects the Inbox (Reports split) navigator. When the flow is opened from Search it never matches the kept expense report, so the else branch ran goBack(keptReportRoute) and opened the kept report in the Inbox instead of returning to Spend > Expenses. For cross-report merges that goBack resolved to a REPLACE (the kept expense report was never on the stack), leaving the torn-down discarded thread reachable via the browser back button, which then rendered a NotFound page. Replace the branch with origin-aware navigation: when opened from Search (the route carries a backTo param) dismiss the modal back to the search results; otherwise dismiss the duplicates modal (popping its history entries) and replace the now-dead thread with the kept report so browser-back lands on a live screen. --- .../TransactionDuplicate/Confirmation.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pages/TransactionDuplicate/Confirmation.tsx b/src/pages/TransactionDuplicate/Confirmation.tsx index 28456f38eca8..7bdc9d618adf 100644 --- a/src/pages/TransactionDuplicate/Confirmation.tsx +++ b/src/pages/TransactionDuplicate/Confirmation.tsx @@ -104,9 +104,7 @@ function Confirmation() { const handleMergeDuplicates = useCallback(() => { const transactionThreadReportID = childReportID ?? generateReportID(); const mergeParams = !childReportID ? {...transactionsMergeParams, transactionThreadReportID} : transactionsMergeParams; - // Server deletes the discarded transaction's now-empty expense report on merge and - // pushes back a "Report not found" payload for it. Hint the guard and redirect to - // the kept transaction's report so the user doesn't land on the discarded one. + // Suppress the NotFound guard for the discarded thread the server tears down on merge. const keptReportRoute = ROUTES.REPORT_WITH_ID.getRoute(mergeParams.reportID); setDeleteTransactionNavigateBackUrl(keptReportRoute); mergeDuplicates({...mergeParams, ...taxData, currentUserAccountID, currentUserLogin: currentUserLogin ?? ''}); @@ -114,13 +112,17 @@ function Confirmation() { Navigation.dismissToSuperWideRHP(); return; } - const topmostReportID = Navigation.getTopmostReportId?.(); - if (topmostReportID === mergeParams.reportID) { + // Opened from Search: dismiss back to the search results instead of opening the kept report in the Inbox. + if (route.params.backTo) { Navigation.dismissModal(); - } else { - Navigation.goBack(keptReportRoute); + return; } - }, [childReportID, transactionsMergeParams, taxData, currentUserAccountID, currentUserLogin, isSuperWideRHPDisplayed]); + // Opened from the discarded thread: pop the modal's history entries, then replace the now-dead + // thread with the kept report so browser-back can't reach its NotFound page. + Navigation.dismissModal({ + afterTransition: () => Navigation.navigate(keptReportRoute, {forceReplace: true}), + }); + }, [childReportID, transactionsMergeParams, taxData, currentUserAccountID, currentUserLogin, isSuperWideRHPDisplayed, route.params.backTo]); const handleResolveDuplicates = useCallback(() => { resolveDuplicates({...transactionsMergeParams, ...taxData, transactionThreadReportIDMap}); From e018c1525f8dab658a30092679dbd10b17fc3974 Mon Sep 17 00:00:00 2001 From: MobileMage Date: Fri, 12 Jun 2026 03:42:42 +0100 Subject: [PATCH 2/3] Use isSearchTopmostFullScreenRoute to detect the Search entry point route.params.backTo is always set on the duplicates confirmation page (Review's keepSelected passes Navigation.getActiveRoute through to the confirmation route), so it can't distinguish the Search entry point from the normal Inbox review flow. Relying on it made the Inbox merge take the dismiss-only branch, skip the forceReplace, and leave the user on the torn-down discarded thread. Detect Search via isSearchTopmostFullScreenRoute instead, matching the delete-expense flow. --- src/pages/TransactionDuplicate/Confirmation.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/TransactionDuplicate/Confirmation.tsx b/src/pages/TransactionDuplicate/Confirmation.tsx index 7bdc9d618adf..b95b4a33263c 100644 --- a/src/pages/TransactionDuplicate/Confirmation.tsx +++ b/src/pages/TransactionDuplicate/Confirmation.tsx @@ -23,6 +23,7 @@ import useTransactionThreadReportIDs from '@hooks/useTransactionThreadReportIDs' import {mergeDuplicates, resolveDuplicates} from '@libs/actions/IOU/Duplicate'; import {setDeleteTransactionNavigateBackUrl} from '@libs/actions/Report'; import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; +import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; import type {TransactionDuplicateNavigatorParamList} from '@libs/Navigation/types'; @@ -113,7 +114,9 @@ function Confirmation() { return; } // Opened from Search: dismiss back to the search results instead of opening the kept report in the Inbox. - if (route.params.backTo) { + // The review flow always sets route.params.backTo (keepSelected passes getActiveRoute), so it can't be used + // to detect the Search entry point — check the topmost full-screen route instead. + if (isSearchTopmostFullScreenRoute()) { Navigation.dismissModal(); return; } @@ -122,7 +125,7 @@ function Confirmation() { Navigation.dismissModal({ afterTransition: () => Navigation.navigate(keptReportRoute, {forceReplace: true}), }); - }, [childReportID, transactionsMergeParams, taxData, currentUserAccountID, currentUserLogin, isSuperWideRHPDisplayed, route.params.backTo]); + }, [childReportID, transactionsMergeParams, taxData, currentUserAccountID, currentUserLogin, isSuperWideRHPDisplayed]); const handleResolveDuplicates = useCallback(() => { resolveDuplicates({...transactionsMergeParams, ...taxData, transactionThreadReportIDMap}); From 1f855b2be647086c0b9777591785933edd12f8ee Mon Sep 17 00:00:00 2001 From: MobileMage Date: Fri, 12 Jun 2026 03:44:45 +0100 Subject: [PATCH 3/3] Trim navigation comments --- src/pages/TransactionDuplicate/Confirmation.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pages/TransactionDuplicate/Confirmation.tsx b/src/pages/TransactionDuplicate/Confirmation.tsx index b95b4a33263c..8585c2ed6c8f 100644 --- a/src/pages/TransactionDuplicate/Confirmation.tsx +++ b/src/pages/TransactionDuplicate/Confirmation.tsx @@ -113,15 +113,12 @@ function Confirmation() { Navigation.dismissToSuperWideRHP(); return; } - // Opened from Search: dismiss back to the search results instead of opening the kept report in the Inbox. - // The review flow always sets route.params.backTo (keepSelected passes getActiveRoute), so it can't be used - // to detect the Search entry point — check the topmost full-screen route instead. + // From Search, dismiss back to the results (backTo is always set here, so it can't detect Search). if (isSearchTopmostFullScreenRoute()) { Navigation.dismissModal(); return; } - // Opened from the discarded thread: pop the modal's history entries, then replace the now-dead - // thread with the kept report so browser-back can't reach its NotFound page. + // From the discarded thread: pop the modal entries, then replace the dead thread with the kept report. Navigation.dismissModal({ afterTransition: () => Navigation.navigate(keptReportRoute, {forceReplace: true}), });