Fix stale duplicate violation persisting after editing transaction amount offline#88298
Conversation
Add shouldShowDuplicateViolation predicate that requires bidirectional confirmation before displaying a duplicatedTransaction violation. A duplicate is only shown if at least one referenced partner also has a matching violation pointing back. This prevents stale violations when OpenReport and UpdateMoneyRequestAmountAndCurrency resolve in different order causing one-sided data. Wire the check into all display paths: useTransactionViolations, getTransactionViolations, hasViolation, isDuplicate, hasVisibleViolationsForUser, and all callers that pass the violations collection. Made-with: Cursor
Cover bidirectional matching, one-sided stale references, missing partners, multi-duplicate lists, and the stale backend response scenario. Made-with: Cursor
Remove the redundant transactionViolation parameter — isDuplicate now looks up the single transaction's violations from the collection internally, eliminating the repeated slice-then-pass pattern at every call site. Made-with: Cursor
|
@thelullabyy Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
…tions Made-with: Cursor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cea558d60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…n subscription Made-with: Cursor
|
To use Codex here, create a Codex account and connect to github. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.different.reports.movweb.one.report.mov |
|
job 1 failing |
PR ReviewApproach: The display-time bidirectional filter ( Failing CI test
const transactionViolations: OnyxCollection<TransactionViolation[]> = {
[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${reportTransaction.transactionID}`]: violations,
};The bidirectional check in Fix options:
Option 1 is the correct fix. Performance consideration
The same full-collection subscription is added in Minor observations
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6bb7e71e5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Revert all changes from the display-time shouldShowDuplicateViolation wiring (isDuplicate signature change, useTransactionViolations full collection subscription, getTransactionViolations/hasViolation filters, and all dependent call-site updates). The successData approach will be used instead. Made-with: Cursor
…tale duplicates When UpdateMoneyRequestAmountAndCurrency resolves, a queued OpenReport command can overwrite the optimistic cleanup with stale one-sided duplicate violations. Pushing the same cleaned value into successData ensures it is re-applied after the server response, preventing the stale data from persisting. Made-with: Cursor
…eTransactionViolation Made-with: Cursor
|
@aimane-chnaif Hey! I've revised the approach based on the perfomance feedback. Here's what changed: Previous approach (reverted): Display-time bidirectional filter ( New approach ( Changes are minimal (3 files):
The PR description has been updated to reflect this. Ready for re-review when you get a chance! |
This comment was marked as outdated.
This comment was marked as outdated.
PR ReviewApproach is sound. Pushing the same cleaned partner violations into All CI checks pass. Code correctness
Tests5 new tests cover the key scenarios well: re-application, optimistic/success parity, null on last removal, failure rollback, and the undefined guard. The One noteThe reviewer comment about the search page still showing duplicate violations ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60806933bb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.62-5 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. The changes are an internal bug fix for a race condition in Onyx data synchronization ( |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.64-0 🚀
Bundle Size Analysis (Sentry): |


Explanation of Change
After Auth#17336 introduced bidirectional duplicate violations, a command ordering issue causes stale one-sided violations to persist in the UI.
Root cause: When transitioning from offline to online,
OpenReportresolves first and writes bidirectional duplicate violations for both transactions A and B. ThenUpdateMoneyRequestAmountAndCurrencyresolves — its optimistic cleanup correctly removes A's duplicate reference from B, but the server response only carries A's updated violations. BecausesuccessDatapreviously did not re-apply the partner cleanup, staleOpenReportdata for B overwrites the optimistic cleanup.Fix:
removeTransactionFromDuplicateTransactionViolationnow pushes the same cleaned partner violations intoonyxData.successDatain addition tooptimisticData. This ensures the cleanup is re-applied after the server response, preventing queued commands likeOpenReportfrom re-introducing one-sided duplicate violations. ThesuccessDatatype ingetUpdateMoneyRequestParamsis widened to acceptTRANSACTION_VIOLATIONSkeys.Changes:
src/libs/TransactionUtils/index.ts— push cleaned partner violations intosuccessDataalongsideoptimisticDatasrc/libs/actions/IOU/UpdateMoneyRequest.ts— widensuccessDatatype union to includeTRANSACTION_VIOLATIONStests/unit/TransactionTest.ts— add 5 unit tests verifyingsuccessDatabehavior (re-application, optimistic/success parity, null on last removal, failure rollback, undefined guard)Fixed Issues
$ #67116
PROPOSAL:
Tests
Offline tests
Same as tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
CleanShot.2026-04-20.at.02.02.43.mp4
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari