Skip to content

[READY FOR PAYMENT][$500] Implement closing the modal with resetting the browser history #78338

Closed

Description

@WojtekBoman

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: v9.2.85-7
Reproducible in staging?: Yes
Reproducible in production?: Yes
Issue reported by: @WojtekBoman

Action Performed:

  1. Launch the app
  2. Go to workspace chat.
  3. Create two expenses with the same amount.
  4. Open the expense report.
  5. Click Review duplicates.
  6. Click on the first expense preview.
  7. Click More > Delete.
  8. Delete the expense.
  9. Click on the browser forward button.

Expected Result:

It's not possible to open closed pages using the browser forward button.

Actual Result:

It's possible to open closed pages using the browser forward button.

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

Screen.Recording.2025-12-23.at.08.15.17.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022003522877557734290
  • Upwork Job ID: 2003522877557734290
  • Last Price Increase: 2026-03-12
Issue OwnerCurrent Issue Owner: @sakluger

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 23, 2025
  2. melvin-bot commented on Dec 23, 2025

    @melvin-bot

    Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. abbasifaizan70 commented on Dec 23, 2025

    @abbasifaizan70
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-12-29 23:43:01 UTC.

    Proposal

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

    When reviewing duplicate expenses and deleting one of them, the browser's forward button still allows navigating to the deleted expense page.

    What is the root cause of that problem?

    The issue is in how navigation is handled after deleting an expense from the Review Duplicates flow. When the user deletes an expense, the app calls onBackButtonPress() which internally uses Navigation.goBack(backTo). This navigates back to the Review Duplicates page but does not clear the browser's forward history.

    The Problem Flow:

    1. User is on Review Duplicates page (entry A in browser history)
    2. User clicks on an expense preview → navigation pushes new entry (entry B) - history: [A, B]
    3. User deletes the expense → onBackButtonPress() is called
    4. Navigation.goBack(backTo) navigates back to A
    5. Browser's forward history still contains entry B (the deleted expense page)
    6. Clicking forward button navigates to the deleted expense page

    Root Cause Location:

    In App/src/components/MoneyRequestHeader.tsx, the delete confirmation handler calls onBackButtonPress() without any special handling for the duplicate review flow:

    // Lines 538-569 - Current implementation
    onConfirm={() => {
        setIsDeleteModalVisible(false);
        // ... deletion logic ...
        onBackButtonPress(); // <-- Uses goBack which doesn't clear forward history
    }}

    The onBackButtonPress function (defined in ReportScreen.tsx) uses Navigation.goBack(backTo):

    // Lines 391-394 in ReportScreen.tsx
    if (prioritizeBackTo && backTo) {
        Navigation.goBack(backTo as Route);  // <-- Doesn't clear forward history
        return;
    }

    Why goBack doesn't work:

    Navigation.goBack(route) internally uses goUp() which either:

    • Pops back to the route if found in current state, OR
    • Replaces the current route

    In either case, the browser's forward history stack is not cleared. The browser's history API maintains its own forward/back stack independent of React Navigation's state.

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

    When deleting an expense from the Review Duplicates flow, use Navigation.navigate(backTo, {forceReplace: true}) instead of onBackButtonPress(). The forceReplace option tells the navigation to use history.replaceState() instead of history.pushState(), which clears the browser's forward history.

    File: App/src/components/MoneyRequestHeader.tsx

    Change:

    onConfirm={() => {
        setIsDeleteModalVisible(false);
        if (!parentReportAction || !transaction) {
            throw new Error('Data missing');
        }
        if (isTrackExpenseAction(parentReportAction)) {
            deleteTrackExpense({
                chatReportID: report?.parentReportID,
                chatReport: parentReport,
                transactionID: transaction.transactionID,
                reportAction: parentReportAction,
                iouReport,
                chatIOUReport,
                transactions: duplicateTransactions,
                violations: duplicateTransactionViolations,
                isSingleTransactionView: true,
                isChatReportArchived: isParentReportArchived,
                isChatIOUReportArchived,
            });
        } else {
            deleteTransactions([transaction.transactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash, true);
            removeTransaction(transaction.transactionID);
        }
    +   // When coming from the Review Duplicates flow, use navigate with forceReplace
    +   // to clear the browser's forward history. This prevents navigating back to the
    +   // deleted expense page using the browser forward button.
    +   if (isFromReviewDuplicates && route.params.backTo) {
    +       Navigation.navigate(route.params.backTo, {forceReplace: true});
    +       return;
    +   }
        onBackButtonPress();
    }}

    Demo

    Screen.Recording.2025-12-30.at.4.41.48.AM.mov
  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 23, 2025
  5. changed the title [-]Implement closing the modal with resetting the browser history[/-] [+][$250] Implement closing the modal with resetting the browser history[/+] on Dec 23, 2025
  6. melvin-bot commented on Dec 23, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 23, 2025
  8. melvin-bot commented on Dec 23, 2025

    @melvin-bot

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

  9. melvin-bot commented on Dec 27, 2025

    @melvin-bot

    @Krishna2323 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  10. Krishna2323 commented on Dec 29, 2025

    @Krishna2323
    Contributor

    Reviewing...

  11. 52 remaining items

  12. melvin-bot commented on Mar 20, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  13. mallenexpensify commented on Mar 20, 2026

    @mallenexpensify
    Contributor

    @marufsharifi paid, summary updated above.
    thx!

    @Krishna2323 plz complete the BZ checklist and tag me in a post once you have. Thx

  14. melvin-bot commented on Mar 20, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  15. Krishna2323 commented on Mar 23, 2026

    @Krishna2323
    Contributor

    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: I couldn't find a single PR that "missed" this case — the concept of isDeletedTransactionThread simply never existed before the fix.

    • [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/615232

    Regression Test Proposal

    Precondition:

    Test:

    Tests
    Test 1: Basic duplicate delete + forward button (online)

    1. Go to a workspace chat
    2. Create two expenses with the same amount (e.g., $10.00 each)
    3. Open the expense report
    4. Click "Review duplicates" in the header
    5. Click on the first expense preview to open it
    6. Click More → Delete → confirm deletion
    7. You should be navigated back to the single expense view page
    8. Click the browser forward button once
    9. ✅ Expected: "Not Found" page (NOT the deleted expense)
    10. Click the browser forward button again (if possible)
    11. ✅ Expected: Still "Not Found" or no navigation

    Test 2: Basic duplicate delete + forward button (offline)

    1. Repeat steps 1-6 from Test 1
    2. Turn off network (airplane mode / disconnect)
    3. Click the browser forward button once
    4. ✅ Expected: "Not Found" page
    5. Click the browser forward button again
    6. ✅ Expected: "Not Found" page
    7. Turn network back on
    8. ✅ Expected: Page remains "Not Found", no errors in console

    Test 3: No brief "Not Found" flash during deletion

    1. Repeat steps 1-6 from Test 1
    2. Watch the screen carefully during step 6 (the delete action)
    3. ✅ Expected: No brief flash of "Not Found" page before navigating back. Should see smooth transition (possibly a loading skeleton, then the Review page).
    4. 🟡 Regression Tests — Existing Deletion Flows

    Test 4: Delete single expense from ReportDetailsPage (existing flow)

    1. Go to a chat and create a single expense
    2. Open the expense
    3. Click the report details (header/3-dot menu)
    4. Delete the expense from the details page
    5. ✅ Expected: Navigates back smoothly, no "Not Found" flash, no errors
    6. Click the browser forward button
    7. ✅ Expected: "Not Found" page (same behavior as staging/main)

    Test 5: Delete expense from MoneyRequestHeader (transaction thread)

    1. Open a chat with a single expense
    2. Click on the expense to open the transaction thread
    3. Click More → Delete → confirm
    4. ✅ Expected: Smooth navigation back, no "Not Found" flash
    5. Click the browser forward button
    6. ✅ Expected: "Not Found" page

    Test 6: Delete expense from MoneyReportHeader (expense report with multiple transactions)

    1. Create a workspace with 3+ expenses in a report
    2. Open the expense report
    3. Open one of the individual expenses
    4. Click More → Delete → confirm
    5. ✅ Expected: Navigates back to the expense report (now with fewer transactions), no flash
    6. Check the expense report displays correctly

    Test 7: Delete last transaction on a report from search

    1. Open Search, find an expense report with a single transaction
    2. Click on the report to open it in the RHP
    3. Delete the transaction
    4. ✅ Expected: Should navigate back or show "Not Found" cleanly — no infinite loading spinner
    5. Click the browser forward button
    6. ✅ Expected: "Not Found" page

    Test 8: Delete from expense report with multiple transactions from search

    1. Open Search, find an expense report with 2+ transactions
    2. Open the report in the RHP
    3. Delete one transaction
    4. ✅ Expected: Report updates to show remaining transactions, no flash
    5. Check that the remaining transaction(s) display correctly

    Test 9: Navigate away from Review Duplicates WITHOUT deleting

    1. Create duplicate expenses → open expense report → click "Review duplicates"
    2. Click on an expense preview
    3. Click the browser back button (don't delete anything)
    4. ✅ Expected: Returns to Review Duplicates page normally
    5. Click forward/back a few times
    6. ✅ Expected: Normal navigation, no "Not Found" showing

    Test 10: "Keep All" on Review Duplicates

    1. Create duplicate expenses → open expense report → click "Review duplicates"
    2. Click "Keep All"
    3. ✅ Expected: Navigates back normally
    4. Click the browser forward button
    5. ✅ Expected: Should NOT show the duplicates review page (or show Not Found)

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-6f15-a53a-4d9f-008c050caf34
  16. Krishna2323 commented on Mar 23, 2026

    @Krishna2323
    Contributor

    @mallenexpensify checklist done ^

  17. mallenexpensify commented on Mar 24, 2026

    @mallenexpensify
    Contributor

    Thanks @Krishna2323 , we're good to close!

  18. m-natarajan commented on Mar 30, 2026

    @m-natarajan

    @Krishna2323
    User not redirected to "Review duplicates" page after deleting the expenses (Test 1, step-7), Can you please update the steps if required

    Recording.2616.mp4
  19. Krishna2323 commented on Apr 4, 2026

    @Krishna2323
    Contributor

    Requested in ND.

  20. Krishna2323 commented on Apr 4, 2026

    @Krishna2323
    Contributor

    User not redirected to "Review duplicates" page after deleting the expenses (Test 1, step-7), Can you please update the steps if required

    @m-natarajan sorry for that. Updated.

  21. twisterdotcom commented on Apr 5, 2026

    @twisterdotcom
    Contributor

    @Krishna2323 has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-8d66-ae13-94ac-95b3c4436234
  22. quinthar commented on Apr 13, 2026

    @quinthar
    Contributor

    Approved $500 to @Krishna2323

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorMonthlyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions