You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-12-02][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense #106975
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 contributorReviewingHas a PR in reviewWeeklyKSv2
After reviewing duplicates and choosing Keep all, reverting the paid expense causes it to show a Potential duplicate badge in the expense list, but the duplicates cannot be reviewed again.
changed the title [-]Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/-][+][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/+]on Nov 16, 2026
After a user reviews duplicates and chooses Keep all, then reverts the paid expense (Cancel payment > Unapprove > Retract), the expense list shows a Potential duplicate badge on the reverted expense, but the report offers no Review duplicates action. The expense is stuck in a dead end: flagged as a potential duplicate, with no way to review it. Expected behavior: an expense marked Potential duplicate should allow re-reviewing duplicates.
I reproduced the exact disagreement in a unit test on HEAD (e91964c). With an open EXPENSE report, the submitter as current user, a present DUPLICATED_TRANSACTION violation, and the stale dismissal marker from the earlier Keep-all review, the live-Onyx gates return isViolationDismissed = true, isDuplicate = false, and getVisibleTransactionViolations = [] (review closed), while the same violation evaluated against the search-snapshot copy of the transaction (no marker) returns it as visible (badge shown). Same violation, same report, same user, two different answers depending on which copy of the transaction the code reads. That is the bug.
Root cause
The Keep-all dismissal and the revert path disagree about what "dismissed" means, because the dismissal marker is client-side only and the violation is re-introduced after the revert:
Keep all writes a client-side-only marker. dismissDuplicateTransactionViolation (src/libs/actions/Transaction.ts:554) removes the DUPLICATED_TRANSACTION violation from both transactions and records transaction.comment.dismissedViolations[duplicatedTransaction][userEmail] = timestamp (Transaction.ts:653-666). The API params (src/libs/API/parameters/DismissViolationParams.ts) carry no comment field, so the marker is never sent to the server; it lives only in live Onyx.
Reverting re-introduces a fresh violation. retractReport (src/libs/actions/IOU/ReportWorkflow.ts:701) sets the report back to OPEN and touches only REPORT and REPORT_ACTIONS, never violations or transactions. Auth re-runs duplicate detection on the status change and pushes a fresh DUPLICATED_TRANSACTION violation for the reverted expense, because the pair still exists and both are now on open reports. Only the reverted expense gets it; the draft side never changed status. The repro video confirms the timing: the badge is already visible on the reverted row while the report is still Outstanding, before Retract is clicked.
Live-Onyx gates treat the fresh violation as dismissed. isViolationDismissed (src/libs/TransactionUtils/violations.ts:386) reads the marker from the live transaction and returns true, so isDuplicate (violations.ts:355) returns false, isReviewDuplicatesAction (src/libs/ReportPrimaryActionUtils.ts:380) is false, and the header offers Submit instead of Review duplicates. DynamicReviewPage reads duplicateTransactionIDs from dismissal-filtered useTransactionViolations, so the review page would also show no duplicates.
The list badge disagrees. TransactionGroupListItem.tsx:546-600 filters violations from the search snapshot, whose server-serialized transaction does not carry comment.dismissedViolations. isViolationDismissed returns false there, the violation passes the filter, and getRBRMessages renders "Potential duplicates".
The marker has no violation instance or version attached, so the live gates cannot distinguish a fresh re-introduced violation from the one already reviewed. The dismissal's real effect is the violation removal itself (optimistic + server-confirmed in dismissDuplicateTransactionViolation); the marker is redundant in every designed flow and unreliable once a violation is re-introduced.
Changes
One single-point fix in src/libs/TransactionUtils/violations.ts, in isViolationDismissed (~line 386). A present DUPLICATED_TRANSACTION violation is never treated as dismissed:
if(!transaction||!violation){returnfalse;}// A present DUPLICATED_TRANSACTION violation is always reviewable. The// dismissal marker in transaction.comment.dismissedViolations is written// client-side only and is never sent to the server, so it goes stale when// Auth re-introduces the violation after the report leaves the settled or// approved state (cancel payment, unapprove, retract). The dismissal's real// effect is the removal of the violation itself, which// dismissDuplicateTransactionViolation already does optimistically and the// server confirms, so this marker is redundant for duplicates.if(violation.name===CONST.VIOLATIONS.DUPLICATED_TRANSACTION){returnfalse;}
Why this placement: isViolationDismissed is the single choke point for every surface that hides a duplicate. isDuplicate (violations.ts:355), getVisibleTransactionViolations (violations.ts:217, used by the list badge and the review page), getTransactionViolations (violations.ts:24, used by the status bar, the submit button, and ReportPrimaryActionUtils), and hasViolation (violations.ts:444) all filter through it. One change makes all of them agree that a present duplicate violation is reviewable. Fixing only isDuplicate would not be enough, because the review page reads duplicateTransactionIDs from useTransactionViolations, which filters through getVisibleTransactionViolations, so the page would still show "No duplicates" while the header offered Review duplicates.
What does not change:
Normal Keep-all flow: after dismiss, the violation is removed from Onyx (optimistic + server-confirmed), so there is no violation for any gate to show. Nothing appears, nothing regresses.
No other violation type is affected. RTER, smartscanFailed, and the rest keep their existing dismissal behavior.
The marker write in dismissDuplicateTransactionViolation stays; it is harmless once unread, and removing it is out-of-scope cleanup.
The approve flow (ReportWorkflow.ts:478) still strips duplicate violations on approve, as before. Merge and removeTransactionFromDuplicateTransactionViolation paths are untouched.
Tests
Baseline on HEAD (e91964c), all green, Node 26.12.1:
New regression tests to add in tests/unit/ViolationUtilsTest.ts, next to the existing isViolationDismissed tests in describe getViolations (using the existing getFakeTransaction, CARLOS_EMAIL, CARLOS_ACCOUNT_ID, and duplicatedTransactionViolation fixtures, with Given/When/Then comments per repo standards):
isViolationDismissed returns false for a DUPLICATED_TRANSACTION violation even when the transaction carries dismissedViolations: {duplicatedTransaction: {[CARLOS_EMAIL]: timestamp}}.
isDuplicate returns true for that same state (open EXPENSE report, submitter = current user, violation present, marker set).
getVisibleTransactionViolations keeps the duplicate violation for that same state (the review-page and list-badge path).
Control: isViolationDismissed still returns true for a smartscanFailed violation with a smartscanFailed marker (existing behavior preserved; already covered by the existing tests, which stay green).
Note on the existing tests: ViolationUtilsTest.ts already tests isViolationDismissed with a duplicatedTransaction violation, but only with a marker for a different violation (dismissedViolations: {smartscanFailed: ...}), so it trivially returns false. No existing test covers a duplicatedTransaction marker on a present DUPLICATED_TRANSACTION violation. That gap is why this bug shipped, and the new tests close it.
After the fix I will re-run tests/unit/ViolationUtilsTest.ts, tests/unit/useTransactionViolationsTest.ts, tests/unit/TransactionTest.ts (the two duplicate describes), and tests/unit/ReportPrimaryActionUtilsTest.ts, and run npm run lint-changed, npm run typecheck, and npm run spell-changed per repo standards.
Alternatives considered
Hide the badge when review is unavailable. Rejected: it contradicts the issue's Expected result (a Potential duplicate expense should allow re-reviewing duplicates) and would paper over the dead end instead of fixing it.
Clear the dismissal marker on the revert path (in retractReport, unapproveExpenseReport, or cancelPayment). Rejected: the badge already appears at Outstanding, before Retract is clicked, so three actions would need the same clearing; retractReport only receives a hasViolations boolean, not the violations themselves; and it would not cover other re-introduction paths (a third duplicate created later, or a stale OpenReport response re-introducing the violation). The read-side carve-out covers all of them.
Server-side fix (Auth stops re-introducing the violation, or search serialization returns the dismissal marker). Rejected for this repo: not shippable from the App repo.
Version the marker or tie it to a violation instance. Rejected: there is no violation instance or version to key on; the marker is a bare timestamp per user email. Adding versioning would be a bigger change across client and server for no extra benefit over the carve-out.
Proposal updated: please review this version of my proposal above (#106975 (comment)), reformatted into the official template. The solution and scope are unchanged.
Please re-state the problem that we are trying to solve in this issue.
After a user reviews duplicates and chooses Keep all, then reverts the paid expense (Cancel payment > Unapprove > Retract), the expense list shows a Potential duplicate badge on the reverted expense, but the report offers no Review duplicates action. The expense is stuck in a dead end: flagged as a potential duplicate, with no way to review it. Expected behavior: an expense marked Potential duplicate should allow re-reviewing duplicates.
I reproduced the exact disagreement in a unit test on HEAD (e91964c). With an open EXPENSE report, the submitter as current user, a present DUPLICATED_TRANSACTION violation, and the stale dismissal marker from the earlier Keep-all review, the live-Onyx gates return isViolationDismissed = true, isDuplicate = false, and getVisibleTransactionViolations = [] (review closed), while the same violation evaluated against the search-snapshot copy of the transaction (no marker) returns it as visible (badge shown). Same violation, same report, same user, two different answers depending on which copy of the transaction the code reads. That is the bug.
What is the root cause of that problem?
The Keep-all dismissal and the revert path disagree about what "dismissed" means, because the dismissal marker is client-side only and the violation is re-introduced after the revert:
Keep all writes a client-side-only marker. dismissDuplicateTransactionViolation (src/libs/actions/Transaction.ts:554) removes the DUPLICATED_TRANSACTION violation from both transactions and records transaction.comment.dismissedViolations[duplicatedTransaction][userEmail] = timestamp (Transaction.ts:653-666). The API params (src/libs/API/parameters/DismissViolationParams.ts) carry no comment field, so the marker is never sent to the server; it lives only in live Onyx.
Reverting re-introduces a fresh violation. retractReport (src/libs/actions/IOU/ReportWorkflow.ts:701) sets the report back to OPEN and touches only REPORT and REPORT_ACTIONS, never violations or transactions. Auth re-runs duplicate detection on the status change and pushes a fresh DUPLICATED_TRANSACTION violation for the reverted expense, because the pair still exists and both are now on open reports. Only the reverted expense gets it; the draft side never changed status. The repro video confirms the timing: the badge is already visible on the reverted row while the report is still Outstanding, before Retract is clicked.
Live-Onyx gates treat the fresh violation as dismissed. isViolationDismissed (src/libs/TransactionUtils/violations.ts:386) reads the marker from the live transaction and returns true, so isDuplicate (violations.ts:355) returns false, isReviewDuplicatesAction (src/libs/ReportPrimaryActionUtils.ts:380) is false, and the header offers Submit instead of Review duplicates. DynamicReviewPage reads duplicateTransactionIDs from dismissal-filtered useTransactionViolations, so the review page would also show no duplicates.
The list badge disagrees. TransactionGroupListItem.tsx:546-600 filters violations from the search snapshot, whose server-serialized transaction does not carry comment.dismissedViolations. isViolationDismissed returns false there, the violation passes the filter, and getRBRMessages renders "Potential duplicates".
The marker has no violation instance or version attached, so the live gates cannot distinguish a fresh re-introduced violation from the one already reviewed. The dismissal's real effect is the violation removal itself (optimistic + server-confirmed in dismissDuplicateTransactionViolation); the marker is redundant in every designed flow and unreliable once a violation is re-introduced.
What changes do you think we should make in order to solve the problem?
One single-point fix in src/libs/TransactionUtils/violations.ts, in isViolationDismissed (~line 386). A present DUPLICATED_TRANSACTION violation is never treated as dismissed:
if(!transaction||!violation){returnfalse;}// A present DUPLICATED_TRANSACTION violation is always reviewable. The// dismissal marker in transaction.comment.dismissedViolations is written// client-side only and is never sent to the server, so it goes stale when// Auth re-introduces the violation after the report leaves the settled or// approved state (cancel payment, unapprove, retract). The dismissal's real// effect is the removal of the violation itself, which// dismissDuplicateTransactionViolation already does optimistically and the// server confirms, so this marker is redundant for duplicates.if(violation.name===CONST.VIOLATIONS.DUPLICATED_TRANSACTION){returnfalse;}
Why this placement: isViolationDismissed is the single choke point for every surface that hides a duplicate. isDuplicate (violations.ts:355), getVisibleTransactionViolations (violations.ts:217, used by the list badge and the review page), getTransactionViolations (violations.ts:24, used by the status bar, the submit button, and ReportPrimaryActionUtils), and hasViolation (violations.ts:444) all filter through it. One change makes all of them agree that a present duplicate violation is reviewable. Fixing only isDuplicate would not be enough, because the review page reads duplicateTransactionIDs from useTransactionViolations, which filters through getVisibleTransactionViolations, so the page would still show "No duplicates" while the header offered Review duplicates.
What does not change:
Normal Keep-all flow: after dismiss, the violation is removed from Onyx (optimistic + server-confirmed), so there is no violation for any gate to show. Nothing appears, nothing regresses.
No other violation type is affected. RTER, smartscanFailed, and the rest keep their existing dismissal behavior.
The marker write in dismissDuplicateTransactionViolation stays; it is harmless once unread, and removing it is out-of-scope cleanup.
The approve flow (ReportWorkflow.ts:478) still strips duplicate violations on approve, as before. Merge and removeTransactionFromDuplicateTransactionViolation paths are untouched.
Tests:
Baseline on HEAD (e91964c), all green, Node 26.12.1:
New regression tests to add in tests/unit/ViolationUtilsTest.ts, next to the existing isViolationDismissed tests in describe getViolations (using the existing getFakeTransaction, CARLOS_EMAIL, CARLOS_ACCOUNT_ID, and duplicatedTransactionViolation fixtures, with Given/When/Then comments per repo standards):
isViolationDismissed returns false for a DUPLICATED_TRANSACTION violation even when the transaction carries dismissedViolations: {duplicatedTransaction: {[CARLOS_EMAIL]: timestamp}}.
isDuplicate returns true for that same state (open EXPENSE report, submitter = current user, violation present, marker set).
getVisibleTransactionViolations keeps the duplicate violation for that same state (the review-page and list-badge path).
Control: isViolationDismissed still returns true for a smartscanFailed violation with a smartscanFailed marker (existing behavior preserved; already covered by the existing tests, which stay green).
Note on the existing tests: ViolationUtilsTest.ts already tests isViolationDismissed with a duplicatedTransaction violation, but only with a marker for a different violation (dismissedViolations: {smartscanFailed: ...}), so it trivially returns false. No existing test covers a duplicatedTransaction marker on a present DUPLICATED_TRANSACTION violation. That gap is why this bug shipped, and the new tests close it.
After the fix I will re-run tests/unit/ViolationUtilsTest.ts, tests/unit/useTransactionViolationsTest.ts, tests/unit/TransactionTest.ts (the two duplicate describes), and tests/unit/ReportPrimaryActionUtilsTest.ts, and run npm run lint-changed, npm run typecheck, and npm run spell-changed per repo standards.
What alternative solutions did you explore? (Optional)
Hide the badge when review is unavailable. Rejected: it contradicts the issue's Expected result (a Potential duplicate expense should allow re-reviewing duplicates) and would paper over the dead end instead of fixing it.
Clear the dismissal marker on the revert path (in retractReport, unapproveExpenseReport, or cancelPayment). Rejected: the badge already appears at Outstanding, before Retract is clicked, so three actions would need the same clearing; retractReport only receives a hasViolations boolean, not the violations themselves; and it would not cover other re-introduction paths (a third duplicate created later, or a stale OpenReport response re-introducing the violation). The read-side carve-out covers all of them.
Server-side fix (Auth stops re-introducing the violation, or search serialization returns the dismissal marker). Rejected for this repo: not shippable from the App repo.
Version the marker or tie it to a violation instance. Rejected: there is no violation instance or version to key on; the marker is a bare timestamp per user email. Adding versioning would be a bigger change across client and server for no extra benefit over the carve-out.
Please re-state the problem that we are trying to solve in this issue.
When a paid expense is reverted (Cancel payment > Unapprove > Retract) after a duplicate review with "Keep all", the expense list displays a "Potential duplicate" badge for the reverted transaction, but opening the expense report does not offer the "Review duplicates" action or permit re-reviewing the duplicates.
What is the root cause of that problem?
The discrepancy occurs between live Onyx state and the search snapshot due to a stale dismissal marker in transaction.comment.dismissedViolations:
When "Keep all" is selected during duplicate review, dismissDuplicateTransactionViolation (in src/libs/actions/Transaction.ts) optimistically removes the DUPLICATED_TRANSACTION violation from Onyx and writes transaction.comment.dismissedViolations[duplicatedTransaction][userEmail] = timestamp. This dismissal marker is strictly client-side Onyx state and is not tracked on the backend transaction record.
When the paid expense is subsequently reverted (via cancelPayment, unapproveExpenseReport, or retractReport), the backend re-evaluates report status and returns the active DUPLICATED_TRANSACTION violation for the transaction because the report is once again open and matches the duplicate pair.
However, isDuplicate (in src/libs/TransactionUtils/violations.ts:380) calls isViolationDismissed, which inspects transaction.comment?.dismissedViolations?.[violation.name]. Because the stale client-side dismissal timestamp from the earlier settled lifecycle is still present, isViolationDismissed evaluates to true, causing isDuplicate to return false. Consequently, isReviewDuplicatesAction in src/libs/ReportPrimaryActionUtils.ts:372 evaluates to false, omitting the "Review duplicates" primary action from the header.
Conversely, the Search / Expense list (TransactionGroupListItem.tsx:546-553) evaluates violations using snapshotTransaction, which is deserialized from the backend search response and does not carry the stale comment.dismissedViolations object. Thus, isViolationDismissed evaluates to false in the list, and the "Potential duplicate" badge is rendered.
What changes do you think we should make in order to solve the problem?
When an expense report workflow is reverted or reopened (e.g. in retractReport, unapproveExpenseReport, or cancelPayment in src/libs/actions/IOU/ReportWorkflow.ts), any stale client-side dismissal marker for DUPLICATED_TRANSACTION on the report's transactions should be cleared in Onyx optimistic data so that re-introduced duplicate violations are properly recognized as active:
In src/libs/actions/IOU/ReportWorkflow.ts (or centrally in retractReport / unapproveExpenseReport):
Include an optimistic Onyx merge for the transactions on the report resetting transaction.comment.dismissedViolations[CONST.VIOLATIONS.DUPLICATED_TRANSACTION] to null.
Additionally, in src/libs/TransactionUtils/violations.ts:
Ensure that if a report is active/open and a fresh duplicate violation is present, a stale dismissal marker from a previous settled lifecycle does not permanently suppress isDuplicate.
This cleanly restores consistency: both the list item badge and the report view header agree that duplicates exist and allow the user to review them again.
What alternative solutions did you consider?
Always ignoring the DUPLICATED_TRANSACTION dismissal marker in isViolationDismissed: Rejected because dismissing duplicates within the current active session is a valid user action that should hide the duplicate warning until the status changes or report is reopened.
Suppressing the list badge: Rejected because the user legitimately has an unreviewed duplicate pair that requires review before submission.
changed the title [-][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/-][+][Due for payment 2026-12-02][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/+]on Dec 2, 2026
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
[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: N/A
[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.
Regression Test Proposal
Precondition:
a workspace with approvals enabled where you are both the submitter and the approver.
Test:
Create a manual expense.
Open its report, submit it, approve it, then select Pay > Mark as paid.
Create the same expense again with the same amount, merchant and date, and wait until it shows Potential duplicate.
Open the new expense, click Review duplicates, then Keep all.
Verify neither expense shows Potential duplicate and the new expense's report shows Submit.
Open the paid expense's report and select More > Cancel payment, then More > Unapprove, then More > Retract.
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 contributorReviewingHas a PR in reviewWeeklyKSv2
Activity
expensify-chore-bot commentedon Nov 16, 2026
Current assignee @gijoe0295 is eligible for the External assigner, not assigning anyone new.
[-]Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/-][+][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/+]expensify-chore-bot commentedon Nov 16, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022122236281581463749
mollfpr commentedon Nov 16, 2026
Weird, can't find @mukhrr in the assignees 🤔
mukhrr commentedon Nov 16, 2026
yeah I am on the process of being added to assignees list soon as a C+
dankezo commentedon Nov 16, 2026
Contributor details
Your Expensify account email: dannyphan190@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Proposal
Problem
After a user reviews duplicates and chooses Keep all, then reverts the paid expense (Cancel payment > Unapprove > Retract), the expense list shows a Potential duplicate badge on the reverted expense, but the report offers no Review duplicates action. The expense is stuck in a dead end: flagged as a potential duplicate, with no way to review it. Expected behavior: an expense marked Potential duplicate should allow re-reviewing duplicates.
I reproduced the exact disagreement in a unit test on HEAD (e91964c). With an open EXPENSE report, the submitter as current user, a present
DUPLICATED_TRANSACTIONviolation, and the stale dismissal marker from the earlier Keep-all review, the live-Onyx gates returnisViolationDismissed= true,isDuplicate= false, andgetVisibleTransactionViolations= [] (review closed), while the same violation evaluated against the search-snapshot copy of the transaction (no marker) returns it as visible (badge shown). Same violation, same report, same user, two different answers depending on which copy of the transaction the code reads. That is the bug.Root cause
The Keep-all dismissal and the revert path disagree about what "dismissed" means, because the dismissal marker is client-side only and the violation is re-introduced after the revert:
dismissDuplicateTransactionViolation(src/libs/actions/Transaction.ts:554) removes theDUPLICATED_TRANSACTIONviolation from both transactions and recordstransaction.comment.dismissedViolations[duplicatedTransaction][userEmail] = timestamp(Transaction.ts:653-666). The API params (src/libs/API/parameters/DismissViolationParams.ts) carry no comment field, so the marker is never sent to the server; it lives only in live Onyx.retractReport(src/libs/actions/IOU/ReportWorkflow.ts:701) sets the report back to OPEN and touches only REPORT and REPORT_ACTIONS, never violations or transactions. Auth re-runs duplicate detection on the status change and pushes a freshDUPLICATED_TRANSACTIONviolation for the reverted expense, because the pair still exists and both are now on open reports. Only the reverted expense gets it; the draft side never changed status. The repro video confirms the timing: the badge is already visible on the reverted row while the report is still Outstanding, before Retract is clicked.isViolationDismissed(src/libs/TransactionUtils/violations.ts:386) reads the marker from the live transaction and returns true, soisDuplicate(violations.ts:355) returns false,isReviewDuplicatesAction(src/libs/ReportPrimaryActionUtils.ts:380) is false, and the header offers Submit instead of Review duplicates.DynamicReviewPagereadsduplicateTransactionIDsfrom dismissal-filtereduseTransactionViolations, so the review page would also show no duplicates.TransactionGroupListItem.tsx:546-600filters violations from the search snapshot, whose server-serialized transaction does not carrycomment.dismissedViolations.isViolationDismissedreturns false there, the violation passes the filter, andgetRBRMessagesrenders "Potential duplicates".The marker has no violation instance or version attached, so the live gates cannot distinguish a fresh re-introduced violation from the one already reviewed. The dismissal's real effect is the violation removal itself (optimistic + server-confirmed in
dismissDuplicateTransactionViolation); the marker is redundant in every designed flow and unreliable once a violation is re-introduced.Changes
One single-point fix in
src/libs/TransactionUtils/violations.ts, inisViolationDismissed(~line 386). A presentDUPLICATED_TRANSACTIONviolation is never treated as dismissed:Why this placement:
isViolationDismissedis the single choke point for every surface that hides a duplicate.isDuplicate(violations.ts:355),getVisibleTransactionViolations(violations.ts:217, used by the list badge and the review page),getTransactionViolations(violations.ts:24, used by the status bar, the submit button, andReportPrimaryActionUtils), andhasViolation(violations.ts:444) all filter through it. One change makes all of them agree that a present duplicate violation is reviewable. Fixing onlyisDuplicatewould not be enough, because the review page readsduplicateTransactionIDsfromuseTransactionViolations, which filters throughgetVisibleTransactionViolations, so the page would still show "No duplicates" while the header offered Review duplicates.What does not change:
dismissDuplicateTransactionViolationstays; it is harmless once unread, and removing it is out-of-scope cleanup.ReportWorkflow.ts:478) still strips duplicate violations on approve, as before. Merge andremoveTransactionFromDuplicateTransactionViolationpaths are untouched.Tests
Baseline on HEAD (e91964c), all green, Node 26.12.1:
tests/unit/ViolationUtilsTest.ts+tests/unit/useTransactionViolationsTest.ts: 267/267 passed.tests/unit/TransactionTest.tsdescribedismissDuplicateTransactionViolation: 5/5 passed.tests/unit/TransactionTest.tsdescriberemoveTransactionFromDuplicateTransactionViolation: 6/6 passed.New regression tests to add in
tests/unit/ViolationUtilsTest.ts, next to the existingisViolationDismissedtests in describegetViolations(using the existinggetFakeTransaction,CARLOS_EMAIL,CARLOS_ACCOUNT_ID, andduplicatedTransactionViolationfixtures, with Given/When/Then comments per repo standards):isViolationDismissedreturns false for aDUPLICATED_TRANSACTIONviolation even when the transaction carriesdismissedViolations: {duplicatedTransaction: {[CARLOS_EMAIL]: timestamp}}.isDuplicatereturns true for that same state (open EXPENSE report, submitter = current user, violation present, marker set).getVisibleTransactionViolationskeeps the duplicate violation for that same state (the review-page and list-badge path).isViolationDismissedstill returns true for asmartscanFailedviolation with asmartscanFailedmarker (existing behavior preserved; already covered by the existing tests, which stay green).Note on the existing tests:
ViolationUtilsTest.tsalready testsisViolationDismissedwith aduplicatedTransactionviolation, but only with a marker for a different violation (dismissedViolations: {smartscanFailed: ...}), so it trivially returns false. No existing test covers aduplicatedTransactionmarker on a presentDUPLICATED_TRANSACTIONviolation. That gap is why this bug shipped, and the new tests close it.After the fix I will re-run
tests/unit/ViolationUtilsTest.ts,tests/unit/useTransactionViolationsTest.ts,tests/unit/TransactionTest.ts(the two duplicate describes), andtests/unit/ReportPrimaryActionUtilsTest.ts, and runnpm run lint-changed,npm run typecheck, andnpm run spell-changedper repo standards.Alternatives considered
retractReport,unapproveExpenseReport, orcancelPayment). Rejected: the badge already appears at Outstanding, before Retract is clicked, so three actions would need the same clearing;retractReportonly receives ahasViolationsboolean, not the violations themselves; and it would not cover other re-introduction paths (a third duplicate created later, or a stale OpenReport response re-introducing the violation). The read-side carve-out covers all of them.melvin-bot commentedon Nov 16, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
dankezo commentedon Nov 16, 2026
Proposal updated: please review this version of my proposal above (#106975 (comment)), reformatted into the official template. The solution and scope are unchanged.
Contributor details
Your Expensify account email: dannyphan190@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Please re-state the problem that we are trying to solve in this issue.
After a user reviews duplicates and chooses Keep all, then reverts the paid expense (Cancel payment > Unapprove > Retract), the expense list shows a Potential duplicate badge on the reverted expense, but the report offers no Review duplicates action. The expense is stuck in a dead end: flagged as a potential duplicate, with no way to review it. Expected behavior: an expense marked Potential duplicate should allow re-reviewing duplicates.
I reproduced the exact disagreement in a unit test on HEAD (e91964c). With an open EXPENSE report, the submitter as current user, a present
DUPLICATED_TRANSACTIONviolation, and the stale dismissal marker from the earlier Keep-all review, the live-Onyx gates returnisViolationDismissed= true,isDuplicate= false, andgetVisibleTransactionViolations= [] (review closed), while the same violation evaluated against the search-snapshot copy of the transaction (no marker) returns it as visible (badge shown). Same violation, same report, same user, two different answers depending on which copy of the transaction the code reads. That is the bug.What is the root cause of that problem?
The Keep-all dismissal and the revert path disagree about what "dismissed" means, because the dismissal marker is client-side only and the violation is re-introduced after the revert:
dismissDuplicateTransactionViolation(src/libs/actions/Transaction.ts:554) removes theDUPLICATED_TRANSACTIONviolation from both transactions and recordstransaction.comment.dismissedViolations[duplicatedTransaction][userEmail] = timestamp(Transaction.ts:653-666). The API params (src/libs/API/parameters/DismissViolationParams.ts) carry no comment field, so the marker is never sent to the server; it lives only in live Onyx.retractReport(src/libs/actions/IOU/ReportWorkflow.ts:701) sets the report back to OPEN and touches only REPORT and REPORT_ACTIONS, never violations or transactions. Auth re-runs duplicate detection on the status change and pushes a freshDUPLICATED_TRANSACTIONviolation for the reverted expense, because the pair still exists and both are now on open reports. Only the reverted expense gets it; the draft side never changed status. The repro video confirms the timing: the badge is already visible on the reverted row while the report is still Outstanding, before Retract is clicked.isViolationDismissed(src/libs/TransactionUtils/violations.ts:386) reads the marker from the live transaction and returns true, soisDuplicate(violations.ts:355) returns false,isReviewDuplicatesAction(src/libs/ReportPrimaryActionUtils.ts:380) is false, and the header offers Submit instead of Review duplicates.DynamicReviewPagereadsduplicateTransactionIDsfrom dismissal-filtereduseTransactionViolations, so the review page would also show no duplicates.TransactionGroupListItem.tsx:546-600filters violations from the search snapshot, whose server-serialized transaction does not carrycomment.dismissedViolations.isViolationDismissedreturns false there, the violation passes the filter, andgetRBRMessagesrenders "Potential duplicates".The marker has no violation instance or version attached, so the live gates cannot distinguish a fresh re-introduced violation from the one already reviewed. The dismissal's real effect is the violation removal itself (optimistic + server-confirmed in
dismissDuplicateTransactionViolation); the marker is redundant in every designed flow and unreliable once a violation is re-introduced.What changes do you think we should make in order to solve the problem?
One single-point fix in
src/libs/TransactionUtils/violations.ts, inisViolationDismissed(~line 386). A presentDUPLICATED_TRANSACTIONviolation is never treated as dismissed:Why this placement:
isViolationDismissedis the single choke point for every surface that hides a duplicate.isDuplicate(violations.ts:355),getVisibleTransactionViolations(violations.ts:217, used by the list badge and the review page),getTransactionViolations(violations.ts:24, used by the status bar, the submit button, andReportPrimaryActionUtils), andhasViolation(violations.ts:444) all filter through it. One change makes all of them agree that a present duplicate violation is reviewable. Fixing onlyisDuplicatewould not be enough, because the review page readsduplicateTransactionIDsfromuseTransactionViolations, which filters throughgetVisibleTransactionViolations, so the page would still show "No duplicates" while the header offered Review duplicates.What does not change:
dismissDuplicateTransactionViolationstays; it is harmless once unread, and removing it is out-of-scope cleanup.ReportWorkflow.ts:478) still strips duplicate violations on approve, as before. Merge andremoveTransactionFromDuplicateTransactionViolationpaths are untouched.Tests:
Baseline on HEAD (e91964c), all green, Node 26.12.1:
tests/unit/ViolationUtilsTest.ts+tests/unit/useTransactionViolationsTest.ts: 267/267 passed.tests/unit/TransactionTest.tsdescribedismissDuplicateTransactionViolation: 5/5 passed.tests/unit/TransactionTest.tsdescriberemoveTransactionFromDuplicateTransactionViolation: 6/6 passed.New regression tests to add in
tests/unit/ViolationUtilsTest.ts, next to the existingisViolationDismissedtests in describegetViolations(using the existinggetFakeTransaction,CARLOS_EMAIL,CARLOS_ACCOUNT_ID, andduplicatedTransactionViolationfixtures, with Given/When/Then comments per repo standards):isViolationDismissedreturns false for aDUPLICATED_TRANSACTIONviolation even when the transaction carriesdismissedViolations: {duplicatedTransaction: {[CARLOS_EMAIL]: timestamp}}.isDuplicatereturns true for that same state (open EXPENSE report, submitter = current user, violation present, marker set).getVisibleTransactionViolationskeeps the duplicate violation for that same state (the review-page and list-badge path).isViolationDismissedstill returns true for asmartscanFailedviolation with asmartscanFailedmarker (existing behavior preserved; already covered by the existing tests, which stay green).Note on the existing tests:
ViolationUtilsTest.tsalready testsisViolationDismissedwith aduplicatedTransactionviolation, but only with a marker for a different violation (dismissedViolations: {smartscanFailed: ...}), so it trivially returns false. No existing test covers aduplicatedTransactionmarker on a presentDUPLICATED_TRANSACTIONviolation. That gap is why this bug shipped, and the new tests close it.After the fix I will re-run
tests/unit/ViolationUtilsTest.ts,tests/unit/useTransactionViolationsTest.ts,tests/unit/TransactionTest.ts(the two duplicate describes), andtests/unit/ReportPrimaryActionUtilsTest.ts, and runnpm run lint-changed,npm run typecheck, andnpm run spell-changedper repo standards.What alternative solutions did you explore? (Optional)
retractReport,unapproveExpenseReport, orcancelPayment). Rejected: the badge already appears at Outstanding, before Retract is clicked, so three actions would need the same clearing;retractReportonly receives ahasViolationsboolean, not the violations themselves; and it would not cover other re-introduction paths (a third duplicate created later, or a stale OpenReport response re-introducing the violation). The read-side carve-out covers all of them.melvin-bot commentedon Nov 16, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
RajGahoi commentedon Nov 16, 2026
Contributor details
Your Expensify account email: gahoiraj01@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~014898525b9c53fc32
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a paid expense is reverted (Cancel payment > Unapprove > Retract) after a duplicate review with "Keep all", the expense list displays a "Potential duplicate" badge for the reverted transaction, but opening the expense report does not offer the "Review duplicates" action or permit re-reviewing the duplicates.
What is the root cause of that problem?
The discrepancy occurs between live Onyx state and the search snapshot due to a stale dismissal marker in
transaction.comment.dismissedViolations:dismissDuplicateTransactionViolation(insrc/libs/actions/Transaction.ts) optimistically removes theDUPLICATED_TRANSACTIONviolation from Onyx and writestransaction.comment.dismissedViolations[duplicatedTransaction][userEmail] = timestamp. This dismissal marker is strictly client-side Onyx state and is not tracked on the backend transaction record.cancelPayment,unapproveExpenseReport, orretractReport), the backend re-evaluates report status and returns the activeDUPLICATED_TRANSACTIONviolation for the transaction because the report is once again open and matches the duplicate pair.isDuplicate(insrc/libs/TransactionUtils/violations.ts:380) callsisViolationDismissed, which inspectstransaction.comment?.dismissedViolations?.[violation.name]. Because the stale client-side dismissal timestamp from the earlier settled lifecycle is still present,isViolationDismissedevaluates totrue, causingisDuplicateto returnfalse. Consequently,isReviewDuplicatesActioninsrc/libs/ReportPrimaryActionUtils.ts:372evaluates tofalse, omitting the "Review duplicates" primary action from the header.TransactionGroupListItem.tsx:546-553) evaluates violations usingsnapshotTransaction, which is deserialized from the backend search response and does not carry the stalecomment.dismissedViolationsobject. Thus,isViolationDismissedevaluates tofalsein the list, and the "Potential duplicate" badge is rendered.What changes do you think we should make in order to solve the problem?
When an expense report workflow is reverted or reopened (e.g. in
retractReport,unapproveExpenseReport, orcancelPaymentinsrc/libs/actions/IOU/ReportWorkflow.ts), any stale client-side dismissal marker forDUPLICATED_TRANSACTIONon the report's transactions should be cleared in Onyx optimistic data so that re-introduced duplicate violations are properly recognized as active:In
src/libs/actions/IOU/ReportWorkflow.ts(or centrally inretractReport/unapproveExpenseReport):Include an optimistic Onyx merge for the transactions on the report resetting
transaction.comment.dismissedViolations[CONST.VIOLATIONS.DUPLICATED_TRANSACTION]tonull.Additionally, in
src/libs/TransactionUtils/violations.ts:Ensure that if a report is active/open and a fresh duplicate violation is present, a stale dismissal marker from a previous settled lifecycle does not permanently suppress
isDuplicate.This cleanly restores consistency: both the list item badge and the report view header agree that duplicates exist and allow the user to review them again.
What alternative solutions did you consider?
DUPLICATED_TRANSACTIONdismissal marker inisViolationDismissed: Rejected because dismissing duplicates within the current active session is a valid user action that should hide the duplicate warning until the status changes or report is reopened.5 remaining items
melvin-bot commentedon Nov 25, 2026
Details
melvin-bot commentedon Nov 25, 2026
Details
mukhrr commentedon Dec 1, 2026
This is due to payment 2026-02-12 and I think we can update price to $250 for the sake of this bug?! @mollfpr what do you think? cc @gijoe0295 @mallenexpensify
[-][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/-][+][Due for payment 2026-12-02][$175] Expenses - Potential duplicate badge appears but duplicates cannot be reviewed after reverting a paid expense[/+]mollfpr commentedon Dec 2, 2026
I agree it was a separate symptom that we handled in the same PR, so I am fine with raising the price to $250. cc @mallenexpensify for the final OK.
expensify-chore-bot commentedon Dec 2, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)expensify-chore-bot commentedon Dec 2, 2026
Payment Summary
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Dec 3, 2026
Matt's AI agent:
Prep notes for the CM. This is not a payment approval. Do not request payment until the CM posts the final amount.
Ready, agreed price.
Job price: $175.
Price basis: standard, no Help Wanted.
Agreed price for mukhrr and gijoe0295: $250. mukhrr asked for it, mollfpr agreed: request, agreement.
The agreed price raises the issue price, and the C+ gets the issue price too. gijoe0295 asked for the same: comment.
Next: pay. No Caps+Y.
Evidence
PAYPREP v1gijoe0295 commentedon Dec 3, 2026
It should be the same price $250 for reviewer cc @mollfpr, @mallenexpensify
gijoe0295 commentedon Dec 3, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: Offline update for Review duplicate Only dismiss the duplicate violation on expenses that have it #106997 (comment)
[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: N/A
[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.
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎