Skip to content

[Due for payment 2026-11-05] [$175] Scan expenses - Multiple scan expenses with different recipients all get added to the workspace of whichever one you tap Submit on #104236

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.10-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @GCyganek
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Create multiple scan expenses.
  2. Assign different recipients to each scan expense, where each recipient belongs to a different workspace.
  3. Tap Submit on one of the scan expenses.
  4. Check where each expense ends up.

Expected Result:

Each scan expense should be added to the workspace associated with its own assigned recipient — i.e., they should end up in separate workspaces, matching the recipient selected for each one.

Actual Result:

All scan expenses end up added to the same workspace — specifically, the workspace associated with whichever scan expense you happened to tap Submit on, regardless of each expense's individually assigned recipient.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Screen.Recording.2026-10-13.at.12.29.14.mov
trim.A214BF68-0613-45A1-8263-A4657B3D5080.MOV

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 16, 2026
  2. MelvinBot commented on Oct 16, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    On the multi-scan confirmation page, the To picker saves the new recipient to the receipt on screen only. But Submit sends every receipt to that one recipient.

    • The picker saves the recipient and report for the visible receipt only (activeTransactionID). So each receipt can store a different recipient.
    • On Submit, the code takes the recipient of the visible receipt (selectedParticipants.at(0)). It then reuses that recipient's report, chat report ID, and policy for every receipt in the loop. It never reads each receipt's own participants or reportID.

    This started with feat: remove isNewManualExpenseFlowEnabled beta flag. Before that PR, tapping To opened the participants step, which applies the recipient to every receipt. So all receipts always shared one recipient, and the submit code was correct. That PR made the in-place picker the only path, and the picker changes only one receipt.

    Code references

    What changes do you think we should make in order to solve the problem?

    Bring back the old behavior: one recipient per multi-scan batch.

    1. Pass the full transactions list into useParticipantPickerState.
    2. In handleParticipantsAdded, when there is more than one receipt, apply the new recipient and report to every receipt. Use the same loop the old participants step used.
    3. Apply the matching category, tag, and rate resets to every receipt too.

    After this change, the To field shows the same recipient on every page, and Submit sends every receipt to that recipient. The submit loop needs no change.

    What alternative solutions did you explore? (Optional)

    Let each receipt keep its own recipient, as the issue's expected result describes. Submit would group receipts by recipient. Then it would find the report, policy, tags, tax, and rate for each group. The track, split, and distance submit hooks would need the same work. This is a much bigger change, and product should confirm they want it first.

    Confidence and verification

    High confidence in the mechanism. I traced it in code at 1708370d but didn't reproduce it on a device.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/104236) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 16, 2026
  4. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (External)

  5. changed the title [-]Scan expenses - Multiple scan expenses with different recipients all get added to the workspace of whichever one you tap Submit on[/-] [+][$175] Scan expenses - Multiple scan expenses with different recipients all get added to the workspace of whichever one you tap Submit on[/+] on Oct 16, 2026
  6. melvin-bot commented on Oct 16, 2026

    @melvin-bot
  7. camesenin commented on Oct 16, 2026

    @camesenin
  8. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    ⚠️ Unable to store contributor details

    Details
    Auth SetContributorDetails returned an error
    401 Contributor details already exist
    
  9. janiya2 commented on Oct 16, 2026

    @janiya2

    Contributor details
    Your Expensify account email: janithad2@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/janithad

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When multiple scan expenses with different recipients (each belonging to a different workspace) are created in a multi-scan flow, tapping "Submit" on one of them adds all scan expenses to the single workspace/recipient of the tapped receipt, rather than routing each expense to its own individually assigned recipient/workspace.

    What is the root cause of that problem?

    There are two interconnected root causes across the multi-scan picker and submission pipeline:

    1. In-place Participant Picker Scope (useParticipantPickerState.ts):
      In src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts (handleParticipantsAdded / lines 190–202), when selecting a recipient in the confirmation step, the recipient and report are updated only for the currently active visible receipt (activeTransactionID). Consequently, individual receipts in the multi-scan batch hold different recipient and report IDs in memory.

    2. Submission Loop Re-uses a Single Context (useRequestMoneySubmission.ts):
      In src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts (lines 163 and 189–266), the submission handler extracts the recipient from the currently active transaction context:

      const participant = selectedParticipants.at(0);

      During the loop (transactions.forEach((transaction) => { ... })), it passes this single participant, its parent report, reportID, and policy to every transaction in the batch instead of inspecting each transaction's own assigned participant / report.
      (Note: useTrackExpenseSubmission.ts:155-183 shares the identical single-recipient loop).

    What changes do you think we should make in order to solve the problem?

    We have two clean approaches depending on product requirements:

    Approach 1 (Recommended — Matches Issue Expected Result):

    Allow multi-scan expenses to route to their respective recipients by grouping transactions by recipient during submission:

    1. In src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts, group transactions by their respective target reportID or participant.accountID:
    --- a/src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts
    +++ b/src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts
    @@ -160,7 +160,11 @@ function useRequestMoneySubmission({
    -    const participant = selectedParticipants.at(0);
    +    // Group transactions by their individual assigned participant / report
    +    const transactionsByReport = useMemo(() => {
    +        return groupTransactionsByAssignedReport(transactions, reports);
    +    }, [transactions, reports]);
    +
         const createDistanceRequest = useCallback(() => { ... }, []);
         const requestMoney = useCallback(() => {
    -        transactions.forEach((transaction) => {
    -            buildAndSubmitRequest({transaction, participant, report});
    -        });
    +        Object.entries(transactionsByReport).forEach(([targetReportID, groupTransactions]) => {
    +            const targetReport = reports?.[targetReportID];
    +            const targetParticipant = getParticipantForReport(targetReport);
    +            groupTransactions.forEach((transaction) => {
    +                buildAndSubmitRequest({transaction, participant: targetParticipant, report: targetReport});
    +            });
    +        });
         }, [transactionsByReport, reports]);

    Approach 2 (Batch Synchronization Alternative):

    If product intends for a multi-scan batch to remain unified under a single recipient (similar to the pre-#100215 flow):
    In src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts:

    --- a/src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts
    +++ b/src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts
    @@ -190,4 +190,8 @@ function useParticipantPickerState({
    -    setTransactionParticipant(activeTransactionID, selectedParticipant);
    +    // Synchronize selected recipient across all transactions in the multi-scan batch
    +    transactions.forEach((tx) => {
    +        setTransactionParticipant(tx.transactionID, selectedParticipant);
    +        resetTransactionCategoryAndTags(tx.transactionID);
    +    });

    What alternative solutions did you explore? (Optional)

    We explored keeping the submission loop as-is and warning the user with a modal if mixed recipients are detected in the carousel. However, Approach 1 is vastly superior because it respects the user's explicit per-receipt recipient selection without artificial constraints.

    Tests

    Automated Tests:

    Add unit test in tests/unit/IOURequestStepConfirmationTest.ts:

    • Create 2 mock scan transactions (tx1, tx2).
    • Assign Workspace A recipient to tx1 and Workspace B recipient to tx2.
    • Trigger submit and verify tx1 calls requestMoney targeting reportA and tx2 targets reportB.

    Manual Verification:

    1. Tap + > Submit expense > Scan.
    2. Scan / upload 2 receipts.
    3. On receipt 1, select recipient belonging to Workspace X.
    4. Swipe / navigate to receipt 2, select recipient belonging to Workspace Y.
    5. Tap Submit.
    6. Verify receipt 1 is submitted to Workspace X report and receipt 2 is submitted to Workspace Y report.
    7. Verify on Web, Desktop, iOS, and Android.
  10. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  11. Metarenessans commented on Oct 17, 2026

    @Metarenessans

    Contributor details
    Your Expensify account email: metarenessans.job@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0126a1db3ee4419254

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In a multi-scan confirmation flow, when different recipients (or different workspaces) are assigned to individual scan receipts in the batch, tapping "Submit" attaches all expenses to the workspace/chat of whichever receipt is currently active on screen, instead of respecting each receipt's individually assigned recipient.

    What is the root cause of that problem?

    1. In src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts (lines 191 & 203), when the user selects a recipient in the "To" picker, the selection is intentionally saved per-transaction to the currently visible receipt:

      setMoneyRequestParticipants(activeTransactionID, participantsList);
      setTransactionReport(activeTransactionID, {reportID: participantReportID}, true);

      Thus, each transaction in transactions correctly stores its own participants and reportID in Onyx.

    2. However, in src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts (lines 164–184):

      • The submission handler extracts only a single participant from selectedParticipants.at(0) (which reflects the currently focused active transaction):
        const participant = selectedParticipants.at(0);
      • It computes the optimisticChatReportID once for that single recipient.
      • Then in lines 190–266, when looping over transactions (for (const item of transactions)), it reuses that same participant and optimisticChatReportID across every expense in the batch, completely ignoring each individual transaction's own assigned item.participants or item.reportID:
        participantParams: {
            payeeEmail: currentUserPersonalDetails.login,
            payeeAccountID: currentUserPersonalDetails.accountID,
            participant,
        },
      • The same issue exists in useTrackExpenseSubmission.ts (line 214).

    What changes do you think we should make in order to solve the problem?

    Depending on Product's intended behavior for multi-scan:

    Approach A (Recommended — Satisfies the Expected Result):

    Allow multi-scan expenses to submit to their respective recipients:

    1. In src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts:
      Inside for (const item of transactions), use each item's individual participant:
    diff --git a/src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts b/src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts
    --- a/src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts
    +++ b/src/pages/iou/request/step/confirmation/submission/useRequestMoneySubmission.ts
    @@ -256,7 +256,7 @@ function useRequestMoneySubmission({
                     participantParams: {
                         payeeEmail: currentUserPersonalDetails.login,
                         payeeAccountID: currentUserPersonalDetails.accountID,
    -                    participant,
    +                    participant: item.participants?.at(0) ?? participant,
                     },
                     policyParams: {
    1. In src/pages/iou/request/step/confirmation/submission/useTrackExpenseSubmission.ts:
      Apply the equivalent per-item participant lookup:
    diff --git a/src/pages/iou/request/step/confirmation/submission/useTrackExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/submission/useTrackExpenseSubmission.ts
    --- a/src/pages/iou/request/step/confirmation/submission/useTrackExpenseSubmission.ts
    +++ b/src/pages/iou/request/step/confirmation/submission/useTrackExpenseSubmission.ts
    @@ -211,7 +211,7 @@ function useTrackExpenseSubmission({
                     participantParams: {
                         payeeEmail: currentUserPersonalDetails.login,
                         payeeAccountID: currentUserPersonalDetails.accountID,
    -                    participant,
    +                    participant: item.participants?.at(0) ?? participant,
                     },
                     policyParams: {
    1. Group transactions by recipient/target report before submitting, so expenses going to the same recipient/workspace batch into the same report, while expenses going to different workspaces create/attach to their respective reports.

    Approach B (Alternative — Uniform Batch Recipient):

    If Product determines that a multi-scan batch must strictly share a single recipient (matching the legacy participant-step behavior):

    • In src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts (handleParticipantsAdded), when transactions.length > 1, iterate over all transactions and update participants and reportID across the entire batch instead of only activeTransactionID:
    diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts b/src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts
    --- a/src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts
    +++ b/src/pages/iou/request/step/IOURequestStepConfirmation/useParticipantPickerState.ts
    @@ -190,4 +190,8 @@ function useParticipantPickerState({
    -            setMoneyRequestParticipants(activeTransactionID, participantsList);
    +            const targetTransactionIDs = transactions.length > 1 ? transactions.map((t) => t.transactionID) : [activeTransactionID];
    +            targetTransactionIDs.forEach((id) => {
    +                setMoneyRequestParticipants(id, participantsList);
    +            });

    What alternative solutions did you explore? (Optional)

    Looked into whether IOURequestStepConfirmation/index.tsx should group multi-scan transactions by workspace prior to rendering the confirmation step. Resolving the recipient during the submission loop is much cleaner and avoids disrupting the swipeable receipt carousel.

  12. camesenin commented on Oct 17, 2026

    @camesenin
  13. 21 remaining items

  14. Kabeer099 commented on Oct 29, 2026

    @Kabeer099
  15. mkhutornyi commented on Oct 30, 2026

    @mkhutornyi
    Contributor

    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: feat: remove isNewManualExpenseFlowEnabled beta flag #100215 (comment)
      Link to the comment on the Issue:

    • [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:

    • [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:

    • Account is a member of at least 2 workspaces (Workspace A, Workspace B)

    Test:

    Test 1: Changing To applies to every receipt

    1. Open the app
    2. Tap + > Create expense > Scan
    3. Turn on multi-scan and capture 3 receipts
    4. Proceed to the confirmation page
    5. On receipt 1, tap To and select Workspace A
    6. Switch to receipt 2 and receipt 3
    7. Verify To shows Workspace A on every receipt
    8. On receipt 3, tap To and select Workspace B
    9. Switch back to receipt 1 and receipt 2
    10. Verify To shows Workspace B on every receipt
    11. Tap Create 3 expenses
    12. Verify all 3 expenses are added to Workspace B

    Test 2: Submit from a different receipt

    1. Repeat steps 1-4 of Test 1
    2. On receipt 2, tap To and select Workspace A
    3. Switch to receipt 3 and tap Create 3 expenses
    4. Verify all 3 expenses are added to Workspace A

    Test 3: Category and tag reset on workspace change

    1. Repeat steps 1-4 of Test 1
    2. Select Workspace A in To, then set a category on receipt 1 and receipt 2
    3. On receipt 3, change To to Workspace B
    4. Switch through all receipts
    5. Verify the Workspace A categories and tags are cleared on every receipt
    6. Tap Create 3 expenses
    7. Verify all 3 expenses are added to Workspace B without Workspace A categories

    Test 4: Individual recipient

    1. Repeat steps 1-4 of Test 1
    2. On receipt 2, tap To and select a user who has no existing chat with you (enter a new email)
    3. Verify To shows that user on every receipt
    4. Tap Create 3 expenses
    5. Verify all 3 expenses are added to one IOU report in the chat with that user

    Test 5: Self DM

    1. Repeat steps 1-4 of Test 1
    2. On receipt 1, tap To and select Workspace A
    3. On receipt 3, tap To and select yourself
    4. Verify To shows yourself on every receipt
    5. Tap Create 3 expenses
    6. Verify all 3 expenses are tracked in your self DM and none are added to Workspace A

    Test 6: Single scan (regression test)

    1. Tap + > Create expense > Scan with multi-scan off and capture 1 receipt
    2. Tap To and select Workspace B
    3. Tap Create expense
    4. Verify the expense is added to Workspace B

    Do we agree 👍 or 👎

  16. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Oct 30, 2026
  17. melvin-bot commented on Nov 4, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. melvin-bot commented on Nov 4, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  19. mallenexpensify commented on Nov 6, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @mkhutornyi due $175 via NewDot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions