Fix duplicate expense report including rejected expenses#89657
Fix duplicate expense report including rejected expenses#89657nabi-ebrahimi wants to merge 1 commit intoExpensify:mainfrom
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@mananjadhav 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05a3e4a740
ℹ️ 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".
| movedToReport = { | ||
| ...existingOpenReport, | ||
| total: (existingOpenReport?.total ?? 0) - transactionAmount, | ||
| }; |
There was a problem hiding this comment.
Preserve original total for rollback in reused report path
prepareRejectMoneyRequestData() now rewrites movedToReport.total to the post-move value before building failureData, but the rollback later still uses movedToReport.total as the "original" value. In the existingOpenReport path, if REJECT_MONEY_REQUEST fails, the rejected report total is no longer restored and remains decremented/incremented, which leaves Onyx totals inconsistent with the actual transaction assignment. This regression is introduced by mutating movedToReport here without retaining the pre-update total for failure handling.
Useful? React with 👍 / 👎.
Explanation of Change
These changes fix an issue where rejecting multiple expenses from the same report could create duplicate rejected-expense reports.
When several expenses are rejected in one flow, the app now keeps track of the newly created rejected report in memory and reuses it for the next rejected expense. This avoids depending on the app state store to update between each rejection, which could lag during the same batch action.
As a result, all rejected expenses from the same source report are moved into one shared rejected report instead of accidentally creating multiple duplicate reports.
Fixed Issues
$ #88236
PROPOSAL: #88236 (comment)
Tests
Preconditions
Create two accounts:
Offline tests
Same as Tests.
QA Steps
Same as Tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
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
Android: Native
Screen.Recording.2026-05-06.at.11.46.50.AM.mov
Android: mWeb Chrome
Screen.Recording.2026-05-06.at.11.50.37.AM.mov
iOS: Native
ios.native.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
macos.mp4