Skip to content

[Due for payment 2026-08-25] [$250] Incorrect Navigation Context After Merging Expenses (Always Redirects to Unreported View) #89799

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number:
Reproducible in staging?: Needs Reproduction (Unable to reproduce)
Reproducible in production?: Needs reproduction
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @garrettmknight
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

Note: This must be tested from the Spend tab. The bug is NOT reproducible from the Inbox tab.

  1. Create Expense A on Report 1 (multi-expense report)
  2. Create Expense B on Report 2
  3. Go to the Spend tab → Reports and open Report 1
  4. Open Expense A from the Report 1 view
  5. Tap More → Merge
  6. Merge with Expense B, selecting Report 1 as the destination
  7. Observe post-merge navigation

Expected Result:

User is redirected to the merged expense view with correct background context:
If merged into a report:
Show Report view in the background
If merged into unreported:
Show Spend → Unreported view in the background

Actual Result:

User is redirected to:
Merged expense view
Background always shows:
Spend → Unreported view, regardless of actual location

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

The video for the issue is in Slack thread

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022052092490808686700
  • Upwork Job ID: 2052092490808686700
  • Last Price Increase: 2026-06-17
Issue OwnerCurrent Issue Owner: @grgia

Activity

  1. added
    Daily
    Bug
    on May 6, 2026
  2. MelvinBot commented on May 6, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The post-merge navigation in ConfirmationPage.tsx:105-110 has three branches:

    1. Search context (line 97) — works correctly.
    2. Report changed (line 105) — only fires when reportID !== targetTransaction.reportID, i.e. the user picked a different report during merge. Calls dismissModalWithReport to navigate to that report.
    3. Default fallthrough (line 110) — calls dismissToSuperWideRHP(), which simply closes the merge modal without navigating anywhere.

    The bug is that the common case — merging expenses where the destination report is the same as the target transaction's report — skips Branch 2 (because reportID === targetTransaction.reportID) and falls through to Branch 3. This just removes the modal, revealing whatever was already in the navigation stack behind it (typically the Unreported/Spend view the user browsed from).

    What changes do you think we should make in order to solve the problem?

    In ConfirmationPage.tsx, the condition on line 105 should be broadened so that dismissModalWithReport is called whenever there is a valid reportIDToDismiss, not only when the report changed. The fix is to remove the reportID !== targetTransaction.reportID check:

    // Before (line 105):
    if (reportIDToDismiss && reportID !== targetTransaction.reportID) {
    
    // After:
    if (reportIDToDismiss) {
    

    This ensures the user is always navigated to the correct report after merge, whether or not the report changed during the merge flow. The Unreported case (reportIDToDismiss is undefined) still falls through to dismissToSuperWideRHP() as intended.

    What alternative solutions did you explore? (Optional)

    An alternative would be to add a new navigation call in the default fallthrough (Branch 3) that explicitly navigates to the target transaction's thread report. However, this would duplicate navigation logic unnecessarily — the simpler fix of widening the existing Branch 2 condition covers all non-search, non-unreported cases in one place.

    Investigation details

    Evidence chain:

    1. User opens an expense from a report view, taps More → Merge (MoneyRequestHeaderSecondaryActions.tsx:338-348)
    2. Merge flow opens (list → details → receipt → confirmation)
    3. User selects Report 1 as destination (same report the target expense is already on)
    4. handleMergeExpenses() fires (line 67)
    5. mergeTransaction.reportID equals targetTransaction.reportID → Branch 2 condition is false
    6. Falls through to dismissToSuperWideRHP() → modal closes, revealing whatever background route was there (Unreported view)

    Related issue: Expensify/App#86817 — "Not here page appears after merging expenses offline & tapping back button" — may share root cause in the same navigation fallthrough logic.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    External
    on May 6, 2026
  4. added
    Help Wanted
    on May 6, 2026
  5. melvin-bot commented on May 6, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (External)

  6. changed the title [-]Incorrect Navigation Context After Merging Expenses (Always Redirects to Unreported View)[/-] [+][$250] Incorrect Navigation Context After Merging Expenses (Always Redirects to Unreported View)[/+] on May 6, 2026
  7. melvin-bot commented on May 6, 2026

    @melvin-bot
  8. KJ21-ENG commented on May 6, 2026

    @KJ21-ENG
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-05-06 18:32:22 UTC.

    Replaces my earlier proposal. The earlier one-line fix only removed the same-report guard, but verified testing showed that is incomplete: report-origin merges can still be routed through the broad topmost-search check, and dismissModalWithReport() opens the generic r/:reportID report route instead of the expense report RHP route e/:reportID.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After merging expenses, the merged expense can open over the wrong background context. When the selected merge destination is an expense report, the background should be that expense report view. When the destination is Unreported, the background should remain Spend > Expenses > Unreported.

    The affected flow is the merge confirmation navigation in handleMergeExpenses():

    const handleMergeExpenses = () => {
    if (!targetTransaction || !mergeTransaction || !sourceTransaction) {
    return;
    }
    const reportID = mergeTransaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID ? (findSelfDMReportID() ?? CONST.REPORT.UNREPORTED_REPORT_ID) : mergeTransaction.reportID;
    setIsMergingExpenses(true);
    mergeTransactionRequest({
    mergeTransactionID: transactionID,
    mergeTransaction,
    targetTransaction,
    sourceTransaction,
    targetTransactionThreadReport,
    targetTransactionThreadParentReport,
    targetTransactionThreadParentReportNextStep,
    allTransactionViolations,
    policy: targetTransactionPolicy,
    policyTags,
    policyCategories,
    currentUserAccountIDParam,
    currentUserEmailParam,
    isASAPSubmitBetaEnabled,
    selfDMReport,
    });
    const reportIDToDismiss = reportID !== CONST.REPORT.UNREPORTED_REPORT_ID ? reportID : undefined;
    const searchReportIDToOpen = targetTransactionThreadReportID ?? reportIDToDismiss;
    // If we're in search (or the topmost route is search), dismiss the modal and open the expense in the RHP
    if ((isOnSearch || isSearchTopmostFullScreenRoute()) && searchReportIDToOpen) {
    Navigation.dismissModal();
    Navigation.setNavigationActionToMicrotaskQueue(() => {
    Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: searchReportIDToOpen}));
    });
    return;
    }
    if (reportIDToDismiss && reportID !== targetTransaction.reportID) {
    Navigation.dismissModalWithReport({reportID: reportIDToDismiss});
    return;
    }
    Navigation.dismissToSuperWideRHP();

    What is the root cause of that problem?

    There are three navigation issues in the confirmation-page exit logic.

    First, the search branch does not rely only on the merge flow's explicit isOnSearch route param. The merge routes already preserve that param through the flow:

    App/src/ROUTES.ts

    Lines 3490 to 3524 in fdb50e6

    MERGE_TRANSACTION_LIST_PAGE: {
    route: 'merge/:transactionID',
    getRoute: (transactionID: string, backTo: string, isOnSearch = false) => {
    // eslint-disable-next-line no-restricted-syntax -- Legacy route generation
    const url = getUrlWithBackToParam(`merge/${transactionID}` as const, backTo);
    return isOnSearch ? (`${url}&isOnSearch=true` as const) : url;
    },
    },
    MERGE_TRANSACTION_RECEIPT_PAGE: {
    route: 'merge/:transactionID/receipt',
    getRoute: (transactionID: string, backTo: string, isOnSearch = false) => {
    // eslint-disable-next-line no-restricted-syntax -- Legacy route generation
    const url = getUrlWithBackToParam(`merge/${transactionID}/receipt` as const, backTo);
    return isOnSearch ? (`${url}&isOnSearch=true` as const) : url;
    },
    },
    MERGE_TRANSACTION_DETAILS_PAGE: {
    route: 'merge/:transactionID/details',
    getRoute: (transactionID: string, backTo: string, isOnSearch = false) => {
    // eslint-disable-next-line no-restricted-syntax -- Legacy route generation
    const url = getUrlWithBackToParam(`merge/${transactionID}/details` as const, backTo);
    return isOnSearch ? (`${url}&isOnSearch=true` as const) : url;
    },
    },
    MERGE_TRANSACTION_CONFIRMATION_PAGE: {
    route: 'merge/:transactionID/confirmation',
    getRoute: (transactionID: string, backTo: string, isOnSearch = false) => {
    // eslint-disable-next-line no-restricted-syntax -- Legacy route generation
    const url = getUrlWithBackToParam(`merge/${transactionID}/confirmation` as const, backTo);
    return isOnSearch ? (`${url}&isOnSearch=true` as const) : url;
    },

    But ConfirmationPage also checks isSearchTopmostFullScreenRoute():

    // If we're in search (or the topmost route is search), dismiss the modal and open the expense in the RHP
    if ((isOnSearch || isSearchTopmostFullScreenRoute()) && searchReportIDToOpen) {
    Navigation.dismissModal();
    Navigation.setNavigationActionToMicrotaskQueue(() => {
    Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: searchReportIDToOpen}));
    });
    return;
    }

    That helper reads the current topmost full-screen route, not where the merge flow was launched from:

    const isSearchTopmostFullScreenRoute = (): boolean => {
    const rootState = navigationRef.getRootState() as State<RootNavigatorParamList>;
    if (!rootState) {
    return false;
    }
    const topmostFullScreenRoute = rootState.routes.findLast((route) => isFullScreenName(route.name));
    return getActiveTabName(topmostFullScreenRoute) === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR;
    };

    So a report-origin merge can be treated as a search-origin merge if Search is the topmost full-screen route underneath the modal stack.

    Second, the report branch is gated by reportID !== targetTransaction.reportID, so same-report merges fall through to dismissToSuperWideRHP():

    if (reportIDToDismiss && reportID !== targetTransaction.reportID) {
    Navigation.dismissModalWithReport({reportID: reportIDToDismiss});
    return;
    }
    Navigation.dismissToSuperWideRHP();

    That helper only pops to an existing wide/super-wide RHP route, or dismisses the modal if none exists; it does not open the selected destination report:

    function dismissToModalStack(modalStackNames: Set<string>, options: {afterTransition?: () => void} = {}) {
    const rootState = navigationRef.getRootState();
    if (!rootState) {
    return;
    }
    const rhpState = rootState.routes.findLast((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.state;
    if (!rhpState) {
    return;
    }
    const lastFoundModalStackIndex = rhpState.routes.slice(0, -1).findLastIndex((route) => modalStackNames.has(route.name));
    const routesToPop = rhpState.routes.length - lastFoundModalStackIndex - 1;
    if (routesToPop <= 0 || lastFoundModalStackIndex === -1) {
    dismissModal(options);
    return;
    }
    navigationRef.dispatch({...StackActions.pop(routesToPop), target: rhpState.key});
    if (options?.afterTransition) {
    TransitionTracker.runAfterTransitions({callback: options.afterTransition, waitForUpcomingTransition: true});
    }
    }
    /**
    * Dismiss top layer modal and go back to the Wide/Super Wide RHP.
    */
    function dismissToPreviousRHP(options: {afterTransition?: () => void} = {}) {
    return dismissToModalStack(ALL_WIDE_RIGHT_MODALS, options);
    }
    function navigateBackToLastSuperWideRHPScreen(options: {afterTransition?: () => void} = {}) {
    return dismissToModalStack(SUPER_WIDE_RIGHT_MODALS, options);
    }
    function dismissToSuperWideRHP(options: {afterTransition?: () => void} = {}) {
    navigateBackToLastSuperWideRHPScreen(options);
    }

    Third, calling dismissModalWithReport() for report destinations is still not enough. dismissModalWithReport() builds ROUTES.REPORT_WITH_ID, which is r/:reportID, while the expected destination surface for this issue is the expense report RHP route e/:reportID:

    const dismissModalWithReport = (
    {reportID, reportActionID, referrer, backTo}: ReportsSplitNavigatorParamList[typeof SCREENS.REPORT],
    ref = navigationRef,
    options?: {onBeforeNavigate?: (willOpenReport: boolean) => void},
    ) => {
    const dismissAndOpenReport = () => {
    const topmostSuperWideRHPReportID = getTopmostSuperWideRHPReportID();
    let areReportsIDsDefined = !!topmostSuperWideRHPReportID && !!reportID;
    if (topmostSuperWideRHPReportID === reportID && areReportsIDsDefined) {
    options?.onBeforeNavigate?.(false);
    dismissToSuperWideRHP();
    return;
    }
    const topmostReportID = getTopmostReportId();
    areReportsIDsDefined = !!topmostReportID && !!reportID;
    const isReportsSplitTopmostFullScreen = isReportTopmostSplitNavigator();
    if (topmostReportID === reportID && areReportsIDsDefined && isReportsSplitTopmostFullScreen) {
    options?.onBeforeNavigate?.(false);
    dismissModal();
    return;
    }
    options?.onBeforeNavigate?.(true);
    const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID, referrer, backTo);
    dismissModal({

    App/src/ROUTES.ts

    Lines 1204 to 1210 in fdb50e6

    REPORT_WITH_ID: {
    route: 'r/:reportID?/:reportActionID?',
    getRoute: (reportID: string | undefined, reportActionID?: string, referrer?: string, backTo?: string) => {
    if (!reportID) {
    Log.warn('Invalid reportID is used to build the REPORT_WITH_ID route');
    }
    const baseRoute = reportActionID ? (`r/${reportID}/${reportActionID}` as const) : (`r/${reportID}` as const);

    App/src/ROUTES.ts

    Lines 632 to 639 in fdb50e6

    EXPENSE_REPORT_RHP: {
    route: 'e/:reportID',
    getRoute: ({reportID, backTo}: {reportID: string; backTo?: string}) => {
    const baseRoute = `e/${reportID}` as const;
    // eslint-disable-next-line no-restricted-syntax -- Legacy route generation
    return getUrlWithBackToParam(baseRoute, backTo);
    },

    What changes do you think we should make in order to solve the problem?

    Update src/pages/TransactionMerge/ConfirmationPage.tsx inside handleMergeExpenses().

    Derive the destination explicitly instead of collapsing report and Unreported destinations into one normalized reportID:

    const isMergingToUnreported = mergeTransaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
    const destinationReportID = isMergingToUnreported ? undefined : mergeTransaction.reportID;
    const fallbackSearchReportID = isMergingToUnreported ? (findSelfDMReportID() ?? CONST.REPORT.UNREPORTED_REPORT_ID) : destinationReportID;

    For search-origin merges, use only the explicit route param isOnSearch. Keep the current behavior of reopening the merged expense in Search RHP with targetTransactionThreadReportID ?? fallbackSearchReportID, but remove isSearchTopmostFullScreenRoute() from this flow.

    For report destinations, build the destination background with ROUTES.EXPENSE_REPORT_RHP.getRoute({reportID: destinationReportID}), not dismissModalWithReport(), because the issue expects the expense report surface (e/:reportID) behind the merged expense.

    The report-destination branch should then be layout-aware:

    • If there is no transaction thread report, dismiss/open only the destination expense report.
    • If the destination is the same report as the target transaction, use Navigation.dismissToPreviousRHP() so the existing RHP stack is reused.
    • If the destination differs, dismiss to/open the destination expense report, then queue Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: targetTransactionThreadReportID, backTo: expenseReportRoute})) so the merged expense opens over that destination report.
    • On wide layout, use dismissToPreviousRHP({afterTransition}) and force-replace the destination expense report route to avoid stacking stale RHP routes.
    • On narrow layout, dismiss the modal and then open the destination expense report.
    • If the merge destination is Unreported, keep falling through to Navigation.dismissToSuperWideRHP().

    Scope boundaries: touch only src/pages/TransactionMerge/ConfirmationPage.tsx in handleMergeExpenses(). No backend/API changes. No changes to mergeTransactionRequest, MergeTransactionUtils, route definitions, or generic navigation helpers. This covers same-report, another-report, search-origin, and Unreported merge destinations.

    What alternative solutions did you explore? (Optional)

    The earlier one-line fix removed reportID !== targetTransaction.reportID. That fixes only the same-report fallthrough, but it does not prevent report-origin merges from being captured by isSearchTopmostFullScreenRoute(), and it still routes report destinations through dismissModalWithReport() / r/:reportID instead of the expected expense report route e/:reportID.

    Abbas Faizan's demo helped confirm the broader direction: split the destination handling, trust the explicit isOnSearch param, and route report destinations to the expense report surface. The implementation above keeps that behavior but scopes it to ConfirmationPage and uses the existing dismissToPreviousRHP / dismissModal transition hooks instead of changing generic navigation helpers.

  9. aswin-s commented on May 6, 2026

    @aswin-s
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user merges two duplicate expenses that belong to the same expense report (in a non-search context), the app incorrectly navigates to the unreported expenses view instead of remaining on or returning to the expense report where the merge occurred. The user expects the post-merge navigation to either stay on the expense report (if it was the topmost screen) or navigate back to it, but instead receives an unexpected redirect to the unreported base view.

    What is the root cause of that problem?

    The bug originates in src/pages/TransactionMerge/ConfirmationPage.tsx in the handleMergeExpenses function at lines 97–110. After merging transactions, the code computes reportIDToDismiss and then checks the condition reportIDToDismiss && reportID !== targetTransaction.reportID before calling dismissModalWithReport.

    When both transactions belong to the same expense report (the typical duplicate-merge case), mergeTransaction.reportID equals targetTransaction.reportID, making the guard reportID !== targetTransaction.reportID evaluate to false. This causes the condition to fail and execution falls through to dismissToSuperWideRHP(), which navigates to the super wide RHP base — resolving to the unreported expenses view in non-search contexts rather than the expense report.

    The guard was likely intended to only navigate to a different report (cross-report merge), but it accidentally excludes the same-report case, which should also navigate to the report. The working analog in src/libs/Navigation/Navigation.ts at lines 828–831 shows that dismissModalWithReport already handles the already-topmost-report case internally with its own guard (topmostSuperWideRHPReportID === reportID), safely falling back to dismissToSuperWideRHP when needed.

    if ((isOnSearch || isSearchTopmostFullScreenRoute()) && searchReportIDToOpen) {
    Navigation.dismissModal();
    Navigation.setNavigationActionToMicrotaskQueue(() => {
    Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: searchReportIDToOpen}));
    });
    return;
    }
    if (reportIDToDismiss && reportID !== targetTransaction.reportID) {
    Navigation.dismissModalWithReport({reportID: reportIDToDismiss});
    return;
    }
    Navigation.dismissToSuperWideRHP();

    if (topmostSuperWideRHPReportID === reportID && areReportsIDsDefined) {
    options?.onBeforeNavigate?.(false);
    dismissToSuperWideRHP();
    return;

    What changes do you think we should make in order to solve the problem?

    1. File: src/pages/TransactionMerge/ConfirmationPage.tsx
      Function: handleMergeExpenses
      Edit: Remove the reportID !== targetTransaction.reportID guard from the condition at line ~110. Change the condition from reportIDToDismiss && reportID !== targetTransaction.reportID to simply reportIDToDismiss. This allows same-report merges to call dismissModalWithReport, which internally handles the already-topmost-report case by falling back to dismissToSuperWideRHP when appropriate. No new imports are required.

      Exact change:

      if (reportIDToDismiss) {
          Navigation.dismissModalWithReport({reportID: reportIDToDismiss});
          return;
      }
      
      Navigation.dismissToSuperWideRHP();
      

      Blast radius: Isolated to the handleMergeExpenses callback within ConfirmationPage. This is an inline callback with a single call site (the Button onPress at line ~150). The fix does not modify dismissModalWithReport; its existing internal guard safely handles the already-topmost-report case, so no adjacent callers are affected.

    What alternative solutions did you explore? (Optional)

    1. Alternative: Modify dismissToSuperWideRHP in src/libs/Navigation/Navigation.ts to accept an optional reportID parameter and navigate to that report instead of the super wide RHP base.
      Rejection reason: Too broad in scope. This would affect every caller across the codebase (17+ callers of dismissModalWithReport and direct callers of dismissToSuperWideRHP), introducing unnecessary risk across unrelated navigation flows. The bug is specific to ConfirmationPage's guard logic, not a deficiency in the navigation helpers themselves.
  10. yusufdeveloper2903 commented on May 6, 2026

    @yusufdeveloper2903
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  11. David-2002065 commented on May 6, 2026

    @David-2002065
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After merging expenses into a report, the merged expense opens over the wrong background — it always shows Spend → Unreported instead of the destination report view.

    What is the root cause of that problem?

    The non-search exit path of handleMergeExpenses ends in dismissToSuperWideRHP():

    if (reportIDToDismiss && reportID !== targetTransaction.reportID) {
    Navigation.dismissModalWithReport({reportID: reportIDToDismiss});
    return;
    }
    Navigation.dismissToSuperWideRHP();

    dismissToSuperWideRHP() does not open the destination report — it only pops the current RHP stack back to a super-wide RHP route that already exists in it:

    function navigateBackToLastSuperWideRHPScreen(options: {afterTransition?: () => void} = {}) {
    return dismissToModalStack(SUPER_WIDE_RIGHT_MODALS, options);
    }
    function dismissToSuperWideRHP(options: {afterTransition?: () => void} = {}) {
    navigateBackToLastSuperWideRHPScreen(options);
    }

    The super-wide set is just SEARCH_MONEY_REQUEST_REPORT and EXPENSE_REPORT:

    const SUPER_WIDE_RIGHT_MODALS = new Set<string>([SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT, SCREENS.RIGHT_MODAL.EXPENSE_REPORT]);

    But the merge flow's modal stack is the MERGE_TRANSACTION stack — it never contains an EXPENSE_REPORT super-wide route. So dismissToModalStack finds nothing (lastFoundModalStackIndex === -1) and degrades to a bare dismissModal(), which just pops the modal and reveals whatever fullscreen route sat underneath — Spend → Unreported:

    const lastFoundModalStackIndex = rhpState.routes.slice(0, -1).findLastIndex((route) => modalStackNames.has(route.name));
    const routesToPop = rhpState.routes.length - lastFoundModalStackIndex - 1;
    if (routesToPop <= 0 || lastFoundModalStackIndex === -1) {
    dismissModal(options);
    return;
    }

    So the mechanism is not merely that the reportID !== targetTransaction.reportID guard is too narrow — it is that the branch it falls into (dismissToSuperWideRHP) was written assuming the destination report's super-wide RHP is already on the stack, which is never true for a merge launched from another context. The destination report is therefore never opened. Note that even routing same-report merges through dismissModalWithReport is not the full fix: that helper builds ROUTES.REPORT_WITH_ID (r/:reportID, the chat report), not the expense report view (e/:reportID) that the issue's Expected Result calls "Report view":

    options?.onBeforeNavigate?.(true);
    const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID, referrer, backTo);
    dismissModal({
    afterTransition: () => {
    navigate(reportRoute, {afterTransition: options?.afterTransition});
    },
    });

    What changes do you think we should make in order to solve the problem?

    For a concrete destination report we should explicitly open the destination expense report (e/:reportID) and reopen the merged-expense thread on top of it, instead of relying on dismissToSuperWideRHP() to find a route that isn't there. In handleMergeExpenses, replace the report branch + fallthrough:

    if (reportIDToDismiss && reportID !== targetTransaction.reportID) {
    Navigation.dismissModalWithReport({reportID: reportIDToDismiss});
    return;
    }
    Navigation.dismissToSuperWideRHP();

    // Concrete destination report: reveal the expense report view, then open the merged expense on top
    if (reportIDToDismiss) {
        const expenseReportRoute = ROUTES.EXPENSE_REPORT_RHP.getRoute({reportID: reportIDToDismiss});
        Navigation.dismissModal({
            afterTransition: () => {
                Navigation.navigate(expenseReportRoute);
                if (targetTransactionThreadReportID) {
                    Navigation.setNavigationActionToMicrotaskQueue(() => {
                        Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: targetTransactionThreadReportID, backTo: expenseReportRoute}));
                    });
                }
            },
        });
        return;
    }
    
    // Only Unreported (no concrete destination report) keeps the existing background
    Navigation.dismissToSuperWideRHP();

    This makes the background the destination expense report view (e/:reportID) and lands the merged expense (the transaction thread) on top, matching both halves of the Expected Result. The Unreported case (reportIDToDismiss === undefined) still falls through to dismissToSuperWideRHP() unchanged.

    Note: removing the reportID !== targetTransaction.reportID guard is still required so same-report merges reach this branch instead of falling through — but on its own that guard removal only swaps one wrong background (Unreported) for another (the chat r/:reportID), which is why the branch needs to target EXPENSE_REPORT_RHP rather than dismissModalWithReport.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Cover the three merge destinations in a non-search context: (1) merge into the same report the target expense is already on → background is that expense report view and the merged expense opens on top; (2) merge into a different report → background is the new destination report; (3) merge into Unreported → background stays Spend → Unreported. Assert the topmost full-screen route after merge for each.

    What alternative solutions did you explore? (Optional)

    A minimal fix is to only widen the guard to if (reportIDToDismiss) and reuse dismissModalWithReport. It fixes the "always Unreported" symptom but lands the user on the chat report (r/:reportID) rather than the expense report view, so it doesn't fully satisfy the Expected Result. The approach above is slightly larger but routes to the correct surface in one place and keeps dismissToSuperWideRHP reserved for the genuine Unreported case.

  12. github-actions commented on May 6, 2026

    @github-actions
    Contributor

    ⚠️ @yusufdeveloper2903 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  13. 15antonian commented on May 6, 2026

    @15antonian

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  14. 139 remaining items

  15. mkhutornyi commented on Aug 21, 2026

    @mkhutornyi

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: No regression. The bug existed for long time

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/675781

    Regression Test Proposal

    Test:

    1. Create Expense A on Report 1 (multi-expense report)
    2. Create Expense B on Report 2
    3. Go to the Spend tab → Reports and open Report 1
    4. Open Expense A from the Report 1 view
    5. Tap More → Merge
    6. Merge with Expense B, selecting Report 1 as the destination
    7. Verify that user is redirected to the merged expense detail view with expense report view (super wide RHP) in the background

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-5028-af4f-e910-bd3954e78d74
  16. mkhutornyi commented on Aug 22, 2026

    @mkhutornyi
    • Proposed amount to increase the price to (mandatory): $500
    • PR - fix super wide RHP closing after merging an expense on Search #96910
    • Deploy blockers audited - no regressions found
    • Scope expansion - inc. cases where scope increased during the PR or effort exceeded initial expectations
      • The original scope was Multi-transaction, source elsewhere ≥2 in the table below but ended up handling 5 different cases
      • For each case, 2 different scenarios (transation detail RHP open or not) were tested and fixed
    • Test coverage - 10 (=5*2) different scenarios tested
    Scenario Post-merge count Result
    One-transaction report already open, source elsewhere 1 single report open
    2 expenses in report → 1 1 single report open
    3 expenses → 2 (source in report) 2 RHP kept open
    Multi-transaction, source elsewhere ≥2 RHP kept open
    Different target/merge report — unchanged

    cc: @grgia

  17. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    • Reviewer: @mkhutornyi owed $250 via NewDot
    • Assignee: @apeyada requires payment (Needs manual offer from BZ)

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  18. mallenexpensify commented on Aug 25, 2026

    @mallenexpensify
    Contributor

    @grgia 👀 above on the proposed price increase, plz

  19. added
    Daily
    and removed
    Daily
    on Aug 25, 2026
  20. grgia commented on Aug 28, 2026

    @grgia
    Contributor

    Thanks for laying out the scenarios so clearly. After reviewing, I'm keeping this at the original $250. The scope of the issue stayed the same throughout: correct navigation after merging an expense. The additional cases handled during review were part of making that fix complete rather than new requirements added along the way, so they fall within the original job.

    That said, the responsiveness and test coverage here were genuinely appreciated.

    @mallenexpensify all set to process at $250 for both.

  21. mallenexpensify commented on Aug 28, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @apeyada paid $250 via Upwork
    Contributor+: @mkhutornyi due $250 via NewDot

  22. mkhutornyi commented on Aug 29, 2026

    @mkhutornyi

    Contributor+: @emkhalid due $250 via NewDot

    @mallenexpensify please update username. Thanks

  23. mallenexpensify commented on Aug 31, 2026

    @mallenexpensify
    Contributor

    Apologies @mkhutornyi . How you're third on this list ¯_(ツ)_/¯

    Image
  24. trjExpensify commented on Sep 17, 2026

    @trjExpensify
    Contributor

    approved $250 for @mkhutornyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions