Repository navigation
Apply the selected recipient to every receipt in a multi-scan batch - #105200
Conversation
Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
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.
|
|
🤖 Web test steps verification results: ❌ fail The test was blocked before it reached the fix, not failed by the fix. The web test tool can't upload files, and the multi-receipt Scan confirmation page that this PR changes can only be reached by uploading receipt images.
|
|
@codex review |
|
@MelvinBot review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🤖 Code reviewLooks good to merge. I found no blocking issues. The change brings the in-place To picker in line with the legacy participants step ( What I checked
Non-blocking notes
|
|
🤖 Web test steps verification results: I found no regressions in the flows I could run on web: a manual expense to a new P2P recipient, a distance expense switched between workspace and P2P recipients, and a split expense all worked with no errors. I couldn't run the 4 scan and multi-scan checks because the web test tool can't upload receipt files, so those rows are marked
|
|
@MelvinBot add QA steps below and mark this PR ready for review Precondition:
Test 1: Changing To applies to every receipt
Test 2: Submit from a different receipt
Test 3: Category and tag reset on workspace change
Test 4: Individual recipient
Test 5: Self DM
Test 6: Single scan (regression test)
Expected Result:Changing To on any receipt in a multi-scan batch updates every receipt. All expenses are added to the selected recipient. |
|
I added your QA steps to the QA Steps section and marked this PR ready for review. I kept the JS console check at the end of the section. I also changed your The Tests section still has the TODO placeholder. You can fill it in or ask me to copy the QA steps there. |
|
@mkhutornyi 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp1.mov2.3.mov4.5.mov6.movAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #104236 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac0741fab6
ℹ️ 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".
| // Every receipt in a multi-scan batch is submitted to the visible receipt's recipient, report and policy, so | ||
| // the selection must apply to all of them, the same way the legacy participants step (useParticipantSubmission) did. | ||
| // Otherwise each receipt shows its own recipient but they all land on whichever one was on screen at submit. | ||
| const transactionsToUpdate = transactions.length > 1 ? transactions : [transaction]; |
There was a problem hiding this comment.
Validate every receipt before assigning a P2P recipient
In a multi-scan batch containing both positive and negative amounts, selecting a P2P recipient while a positive receipt is displayed now assigns that recipient to every transaction, even though shouldKeepOnSelfDM and the picker's P2P exclusion inspect only the displayed transaction. The negative receipt is therefore moved to a P2P chat, which this hook explicitly notes does not support negative amounts, causing the batch to fail at submission; evaluate the guard across transactionsToUpdate before propagating the selection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
(Neil's AI agent)
Valid edge case, but not blocking for this PR. The PR doesn't introduce it:
- On
main, submit already sends every receipt in the batch to the visible receipt's recipient (selectedParticipants.at(0), reused in the loop overtransactions). So a negative receipt in a batch submitted to a P2P recipient already failed the same way. - The legacy participants step has the same single-receipt check (
shouldKeepNegativeExpenseOnSelfDMreads only the initial transaction) and still applies the selection to every draft. - Mixed positive and negative receipts in one multi-scan batch are rare, since scans start at 0 and need a manually entered negative amount.
This PR makes the To field match where the receipts actually go. Checking transactionsToUpdate.some((t) => (t.amount ?? 0) < 0) would be a good follow-up.
neil-marcellini
left a comment
There was a problem hiding this comment.
(Neil's AI agent, human reviewed)
Looks good, one non-blocking comment.
|
|
||
| // Then the receipt that isn't on screen is moved too, because submitting sends every receipt in the batch to | ||
| // the visible receipt's recipient, so a different recipient on another receipt would be silently ignored | ||
| const secondDraftTransaction = await new Promise<OnyxEntry<Transaction>>((resolve) => { |
There was a problem hiding this comment.
(Neil's AI agent, human reviewed)
NAB: this is the same as getDraftTransaction apart from the key. Could getDraftTransaction take an optional transactionID (defaulting to TRANSACTION_ID) so this becomes getDraftTransaction(SECOND_TRANSACTION_ID)?
|
I'm going to skip the review from the product person Jenna because we already discussed with product people in Slack, as linked in the proposal comment on the issue. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 neil-marcellini 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/neil-marcellini in version: 9.5.25-0 🚀
|
|
No help site update needed. This bug fix makes the To field on the multi-scan confirmation page match where the expenses already go, and no existing article says otherwise. Create an Expense is still accurate. |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.25-2 🚀
Bundle Size Analysis (Sentry): |
















Explanation of Change
On the multi-scan confirmation page, the in-place To picker only wrote the selected recipient (and its report, category/tag resets and distance rate) to the receipt on screen. Submitting, however, sends every receipt in the batch to the visible receipt's recipient, report and policy. So each receipt could show a different recipient while all of them ended up in the workspace of whichever receipt was on screen when Submit was tapped.
This brings back the behavior of the legacy participants step (
useParticipantSubmission), which applied the selection to every draft transaction:useParticipantPickerStatenow receives the fulltransactionslist from the confirmation page.handleParticipantsAddedapplies the participants, report, category/tag resets and rate updates to every receipt. A single optimistic report ID is generated so all receipts share the same new P2P chat.The To field now shows the same recipient on every page, matching where the expenses are actually submitted. The submit hooks need no change.
Added a UI test that confirms two scanned receipts and checks that selecting a new workspace moves both of them (it fails without this change).
Fixed Issues
$ #104236
PROPOSAL: #104236 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.
Offline tests
QA Steps
Precondition:
Test 1: Changing To applies to every receipt
Test 2: Submit from a different receipt
Test 3: Category and tag reset on workspace change
Test 4: Individual recipient
Test 5: Self DM
Test 6: Single scan (regression test)
Expected Result:
Changing To on any receipt in a multi-scan batch updates every receipt. All expenses are added to the selected recipient.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
AI Tests
npm run lint-changednpm run typechecknpm run fmt(no formatting changes)npm run spell-changednpm run react-compiler-compliance-check check <changed files>npm test -- tests/ui/components/IOURequestStepConfirmationPageTest.tsx tests/ui/IOURequestStartPageManualTabTest.tsx tests/ui/TimeExpenseConfirmationTest.tsx(58 passed; the new test fails without the fix)npm test,npm run lint, Storybook smoke test (left to CI)