Fix duplicate expense report including rejected expenses#89657
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 👍 / 👎.
There was a problem hiding this comment.
Addressed, I preserved the original rejected report total before building movedToReport and now use that saved value in failureData, so rollback restores the correct total if REJECT_MONEY_REQUEST fails.
flaviadefaria
left a comment
There was a problem hiding this comment.
The fix makes sense to me from a product standpoint.
|
@nabi-ebrahimi Can you please fix the lint errors? |
|
@mananjadhav, addressed, thanks |
|
@mananjadhav, kindly bump. thanks. |
|
I am in between a priority PR. I'll be able to review the new changes tomorrow. |
|
@mananjadhav, gentle bump. thanks. |
|
@mananjadhav, quick bump. thanks. |
|
Apologies for the delay. I just want to check if there'll be any stale reports. Still figuring out the final checks, should have it by Monday. |
mananjadhav
left a comment
There was a problem hiding this comment.
Code LGTM. On testing.
|
@mananjadhav, gentle bump. thanks. |
|
@mananjadhav, friendly bump. thanks. |
|
@nabi-ebrahimi can you resolve the conflicts? @mananjadhav - can you leave a review? Thanks. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid-duplicate-expense.movAndroid: mWeb Chromemweb-chrome-duplicate-expense.moviOS: HybridAppios-duplicate-expense.moviOS: mWeb Safarimweb-safari-duplicate-expense.movMacOS: Chrome / Safariweb-duplicate-expense.mov |
|
@nabi-ebrahimi I just saw we've got some tests for @tylerkaraszewski wdyt? |
mananjadhav
left a comment
There was a problem hiding this comment.
Raised a question on tests.
|
Thanks for the quick action @nabi-ebrahimi. @tylerkaraszewski All yours. |
|
🚧 @tylerkaraszewski has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
This comment has been minimized.
This comment has been minimized.
|
🚧 @tylerkaraszewski 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/tylerkaraszewski in version: 9.3.83-0 🚀
Bundle Size Analysis (Sentry): |
|
I've reviewed the changes in this PR and the help site articles under No help site changes are required. This PR is a purely internal bug fix that prevents duplicate rejected-expense reports when rejecting multiple expenses from the same report in a batch. The changes are limited to internal action logic ( The existing help site article (Approve-Expenses.md) already correctly describes the rejection workflow, and this PR simply fixes the implementation to match that documented behavior. @nabi-ebrahimi, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
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