Skip to content

[Due for payment 2026-03-11] [$250] The duplicates review page is shown when clicking the browser forward button #83532

Closed

Description

@mitarachim

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.3.26-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #79530
Email or phone of affected tester (no customers): applausetester+ds@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Mac 14.5/ Chrome
App Component: Money Requests

Action Performed:

  1. Create duplicate expenses → open expense report → click "Review duplicates"
  2. Click "Keep All"
  3. Click the browser forward button

Expected Result:

Should NOT show the duplicates review page (or show Not Found)

Actual Result:

Shows the duplicates review page

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7088660_1772054906158.bug33.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @laurenreidexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026887611542236135
  • Upwork Job ID: 2026887611542236135
  • Last Price Increase: 2026-03-05

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 26, 2026
  2. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to @laurenreidexpensify (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. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

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

    After resolving duplicate expenses by clicking "Keep All" on the duplicates review page, pressing the browser forward button re-opens the duplicates review page. The page should either show "Not Found" or redirect away, since the duplicates have already been resolved.

    What is the root cause of that problem?

    The shouldShowNotFound guard in Review.tsx (line 166) only checks whether the transaction was deleted or whether transactionID is missing:

    const shouldShowNotFound = !isNavigatingBackToDeletedReview && (wasTransactionDeleted || (!isLoadingPage && !transactionID));
    

    It does not check whether the DUPLICATED_TRANSACTION violation still exists (i.e., whether there are actually duplicates to review).

    When "Keep All" is clicked (line 98-108), dismissDuplicateTransactionViolation() optimistically removes the DUPLICATED_TRANSACTION violation from Onyx (Transaction.ts line 591-595), then Navigation.goBack() is called. This pushes the review page URL into the browser's forward history. When the user presses the forward button, the Review page re-renders — the transaction still exists so shouldShowNotFound is false, but duplicateTransactionIDs is now empty (the violation was removed). The page renders in a broken state with a single transaction and no actual duplicates to review.

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

    In src/pages/TransactionDuplicate/Review.tsx, extend the shouldShowNotFound condition on line 166 to also show "Not Found" when the page has loaded but there are no duplicate transaction IDs (meaning the DUPLICATED_TRANSACTION violation no longer exists):

    Add a condition that checks duplicateTransactionIDs.length === 0 when the page is not loading and a transactionID exists. This way, if the user navigates forward to the review page after resolving duplicates, the page correctly shows the "Not Found" view instead of a broken review UI.

    What alternative solutions did you explore? (Optional)

    1. Adding a useEffect that calls Navigation.goBack() when duplicates are empty — This would redirect the user away, but showing the "Not Found" page is more consistent with how other resolved/deleted entity pages behave in the app.
    2. Using history.replaceState in the keepAll navigation — This would prevent the forward history entry from existing entirely, but it would require changes to the Navigation layer and could have broader implications.
    Detailed Investigation

    Root Cause Analysis

    The duplicate review flow works as follows:

    1. Review.tsx reads transaction violations via useTransactionViolations hook (line 52) and extracts duplicateTransactionIDs from the DUPLICATED_TRANSACTION violation's data.duplicates array (lines 53-56)
    2. transactionIDs combines the main transactionID with duplicateTransactionIDs (line 57)
    3. When "Keep All" is clicked, dismissDuplicateTransactionViolation() optimistically removes the DUPLICATED_TRANSACTION violation from the TRANSACTION_VIOLATIONS Onyx collection and marks it as dismissed in transaction.comment.dismissedViolations
    4. Navigation.goBack() navigates away

    On browser forward navigation:

    • The page re-mounts/re-renders
    • transactionViolations no longer contains DUPLICATED_TRANSACTION (it was removed optimistically)
    • duplicateTransactionIDs becomes []
    • transactionIDs becomes [transactionID] (just the original transaction)
    • shouldShowNotFound evaluates to false because the transaction still exists
    • The page renders with a single transaction in the list and a working "Keep All" button — a broken state

    Evidence Chain

    • Review.tsx:53-56 — duplicateTransactionIDs derived from DUPLICATED_TRANSACTION violation → empty after Keep All
    • Review.tsx:98-108 — keepAll() calls dismissDuplicateTransactionViolation() then Navigation.goBack()
    • Transaction.ts:591-595 — Optimistic data filters out DUPLICATED_TRANSACTION violation entirely
    • Review.tsx:166 — shouldShowNotFound only guards against deleted transactions, not resolved duplicates
    • No useEffect or useFocusEffect in Review.tsx checks for empty duplicates

    Relevant Code

    • src/pages/TransactionDuplicate/Review.tsx:166 — The shouldShowNotFound condition (root cause)
    • src/pages/TransactionDuplicate/Review.tsx:53-57 — duplicateTransactionIDs and transactionIDs derivation
    • src/pages/TransactionDuplicate/Review.tsx:98-108 — The keepAll function
    • src/libs/actions/Transaction.ts:591-595 — Optimistic violation removal
    • src/hooks/useTransactionViolations.ts:17-26 — Violation filtering hook

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 26, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 26, 2026
  6. melvin-bot commented on Feb 26, 2026

    @melvin-bot

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

  7. melvin-bot commented on Feb 26, 2026

    @melvin-bot
  8. changed the title [-]The duplicates review page is shown when clicking the browser forward button[/-] [+][$250] The duplicates review page is shown when clicking the browser forward button[/+] on Feb 26, 2026
  9. ryntgh commented on Feb 26, 2026

    @ryntgh
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-26 05:22:43 UTC.

    Proposal

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

    The duplicates review page is shown when clicking the browser forward button

    What is the root cause of that problem?

    When "Keep All" is clicked, we uses Navigation.goBack, which pops the stack but does not remove the duplicates review URL from browser history. That leaves the page in the history, so the browser forward button can navigate back to it.

    const keepAll = () => {
    dismissDuplicateTransactionViolation({
    transactionIDs,
    dismissedPersonalDetails: currentPersonalDetails,
    expenseReport,
    policy,
    isASAPSubmitBetaEnabled,
    allTransactions,
    });

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

    In keepAll, navigate to backTo with forceReplace: true instead of Navigation.goBack, so the duplicates review entry is replaced in browser history and the forward button no longer returns to it.

        const keepAll = () => {
            dismissDuplicateTransactionViolation({
                transactionIDs,
                dismissedPersonalDetails: currentPersonalDetails,
                expenseReport,
                policy,
                isASAPSubmitBetaEnabled,
                allTransactions,
            });
            const backToRoute = route.params.backTo ?? (report?.parentReportID ? ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID) : ROUTES.HOME);
            Navigation.navigate(backToRoute, {forceReplace: true});
        };

    const keepAll = () => {
    dismissDuplicateTransactionViolation({
    transactionIDs,
    dismissedPersonalDetails: currentPersonalDetails,
    expenseReport,
    policy,
    isASAPSubmitBetaEnabled,
    allTransactions,
    });

    What alternative solutions did you explore? (Optional)

    Include "no duplicates to review" in shouldShowNotFound. So when we have a transactionID and duplicateTransactionIDs is empty (violations were dismissed), show the Not Found view.

        const shouldShowNotFound =
            !isNavigatingBackToDeletedReview && (wasTransactionDeleted || (!isLoadingPage && !transactionID) || (!isLoadingPage && !!transactionID && duplicateTransactionIDs.length === 0));

    const shouldShowNotFound = !isNavigatingBackToDeletedReview && (wasTransactionDeleted || (!isLoadingPage && !transactionID));

    We should update the shouldShowNotFound condition for another duplicate review page as well (ReviewBillable, ReviewCategory, Confirmation, etc)

        const [transactionViolations, transactionViolationsResult] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${getNonEmptyStringOnyxID(transactionID)}`);

    const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${getNonEmptyStringOnyxID(transactionID)}`);

        const shouldShowNotFoundPage =
            isEmptyObject(report) ||
            (!ReportUtils.isValidReport(report) && !isDismissingRef.current) ||
            ReportUtils.isReportNotFound(report) ||
            (reviewDuplicatesResult.status === 'loaded' && (!newTransaction?.transactionID || !doesTransactionBelongToReport)) ||
            (!!transactionID && !isLoadingOnyxValue(transactionViolationsResult) && allDuplicateIDs.length === 0);

    const shouldShowNotFoundPage =
    isEmptyObject(report) ||
    (!ReportUtils.isValidReport(report) && !isDismissingRef.current) ||
    ReportUtils.isReportNotFound(report) ||
    (reviewDuplicatesResult.status === 'loaded' && (!newTransaction?.transactionID || !doesTransactionBelongToReport));

  10. abbasifaizan70 commented on Feb 26, 2026

    @abbasifaizan70
    Contributor

    Proposal

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

    The duplicates review page remains accessible after Keep All via browser forward. Should NOT show the duplicates review page (or show Not Found).

    Actual Result:
    Shows the duplicates review page.

    What is the root cause of that problem?

    The duplicates review screen does not validate that a duplicate violation still exists before rendering.
    After tapping Keep All, we optimistically dismiss the duplicate violation, but the review route still remains in browser history; navigating forward reopens the route and it still renders as valid.

    const keepAll = () => {
    dismissDuplicateTransactionViolation({
    transactionIDs,
    dismissedPersonalDetails: currentPersonalDetails,
    expenseReport,
    policy,
    isASAPSubmitBetaEnabled,
    allTransactions,
    });
    Navigation.goBack();
    };

    // eslint-disable-next-line rulesdir/no-negated-variables
    const shouldShowNotFound = !isNavigatingBackToDeletedReview && (wasTransactionDeleted || (!isLoadingPage && !transactionID));

    dismissDuplicateTransactionViolation() already removes DUPLICATED_TRANSACTION violations optimistically, so the route should become invalid once dismissal happens.

    const optimisticDataTransactionViolations: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS>> = currentTransactionViolations.map((transactionViolations) => ({
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionViolations.transactionID}`,
    value: transactionViolations.violations?.filter((violation) => violation.name !== CONST.VIOLATIONS.DUPLICATED_TRANSACTION),
    }));

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

    diff --git a/src/pages/TransactionDuplicate/Review.tsx b/src/pages/TransactionDuplicate/Review.tsx
    @@
         const duplicateTransactionIDs = useMemo(
             () => transactionViolations?.find((violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)?.data?.duplicates ?? [],
             [transactionViolations],
         );
         const transactionIDs = useMemo(() => (transactionID ? [transactionID, ...duplicateTransactionIDs] : duplicateTransactionIDs), [transactionID, duplicateTransactionIDs]);
    +    const hasDuplicateTransactions = duplicateTransactionIDs.length > 0;
    @@
         const keepAll = () => {
             dismissDuplicateTransactionViolation({
                 transactionIDs,
                 dismissedPersonalDetails: currentPersonalDetails,
                 expenseReport,
                 policy,
                 isASAPSubmitBetaEnabled,
                 allTransactions,
             });
    -        Navigation.goBack();
    +        Navigation.goBack(route.params.backTo);
         };
    @@
    -    const shouldShowNotFound = !isNavigatingBackToDeletedReview && (wasTransactionDeleted || (!isLoadingPage && !transactionID));
    +    const shouldShowNotFound = !isNavigatingBackToDeletedReview && (wasTransactionDeleted || (!isLoadingPage && (!transactionID || !hasDuplicateTransactions)));

    Demo

    Screen.Recording.2026-02-26.at.12.26.01.PM.mov
  11. rojiphil commented on Feb 27, 2026

    @rojiphil
    Contributor

    Showing Not found page when the transaction does not exist makes sense. However, it seems odd to show the Not Found page when the transaction exists. Here, when the user navigates forward to the transaction duplicate review page, there are no duplicates and, hence, no need for a review here. Maybe showing a separate page like ConfirmationPage component makes more sense here.

    function ConfirmationPage({

    @MelvinBot Please include an additional alternative solution in the proposal for displaying a separate page when duplicateTransactionIDs.length === 0 e.g. a ConfirmationPage with a descriptive message, something like There are no duplicate transactions for review here.

  12. 16 remaining items

  13. melvin-bot commented on Mar 4, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  14. melvin-bot commented on Mar 4, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.30-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-03-11. 🎊

    For reference, here are some details about the assignees on this issue:

    • @rojiphil requires payment through NewDot Manual Requests
  15. melvin-bot commented on Mar 4, 2026

    @melvin-bot

    @rojiphil @laurenreidexpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  16. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  17. laurenreidexpensify commented on Mar 11, 2026

    @laurenreidexpensify
    Contributor

    Payment Summary

    • @rojiphil requires payment through NewDot Manual Requests $250
  18. quinthar commented on Apr 13, 2026

    @quinthar
    Contributor

    Approved $250 to @rojiphil

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions