Skip to content

[Due for payment 2026-03-06] Dev: Unable to send invoice from business invoice room #82580

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number:
Reproducible in staging?: Needs Reproduction (Unable to reproduction)
Reproducible in production?: Needs Reproduction
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: @shubham1206agra
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Open any B2B Invoice room
  2. Try to send invoice of any amount
  3. Observe the error when request gets processed.

Expected Result:

No error displayed and user able to send invoice

Actual Result:

Unexpected error creating this chat. Please try again later error message displayed

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-02-16.at.10.41.30.PM.mov

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @kadiealexander

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 16, 2026
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 16, 2026
  3. melvin-bot commented on Feb 16, 2026

    @melvin-bot

    Current assignee @shubham1206agra is eligible for the External assigner, not assigning anyone new.

  4. melvin-bot commented on Feb 16, 2026

    @melvin-bot

    Triggered auto assignment to @kadiealexander (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. melvin-bot commented on Feb 16, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  6. MelvinBot commented on Feb 18, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a user opens a B2B Invoice room and tries to send an invoice of any amount, the request fails with the error: "Unexpected error creating this chat. Please try again later."

    What is the root cause of that problem?

    The SendInvoice flow on the client side does not properly handle B2B (business-to-business) invoice receivers. A B2B invoice room has invoiceReceiver: { type: 'policy', policyID: '...' }, but the code assumes the receiver always has an accountID (the individual receiver case).

    The failure chain:

    1. doesReportReceiverMatchParticipant() (ReportUtils.ts:1720-1722) only checks 'accountID' in report.invoiceReceiver. For B2B rooms where the receiver has policyID instead, this always returns false — so the existing B2B invoice room is never recognized as a valid match.

    2. In IOURequestStepConfirmation.tsx:232-234, receiverAccountID defaults to 0 (since the B2B receiver has no accountID), and receiverParticipantAccountID becomes undefined.

    3. useParticipantsInvoiceReport (useParticipantsInvoiceReport.ts:49-67) is called with receiverID=0 — it supports B2B matching by policyID, but receives the wrong input so finds nothing.

    4. Both matching paths fail, so invoiceChatReport is null and the code falls through to create a new optimistic chat report.

    5. In getSendInvoiceInformation() (SendInvoice.ts:801), since invoiceChatReport is undefined, it sends receiverEmail: '' (empty string) instead of receiverInvoiceRoomID. This is because getPersonalDetailsForAccountID(0) returns {} (since !0 is truthy in JS), so receiver.login is undefined.

    6. The backend rejects the request (empty receiverEmail, no receiverInvoiceRoomID), triggering the pre-defined failureData which sets errorFields.createChat with the generic error message.

    Additionally, buildOptimisticChatReport (ReportUtils.ts:7842-7848) has a TODO comment: "update to support workspace as an invoice receiver when workspace-to-workspace invoice room implemented" — it hardcodes invoiceReceiver as {type: 'individual', accountID: ...}, confirming B2B support was never completed here.

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

    The fix needs to handle B2B receivers (identified by policyID) alongside individual receivers (identified by accountID) in several locations:

    1. doesReportReceiverMatchParticipant in ReportUtils.ts:1720-1722 — Extend to also match business receivers by policyID. The function should accept a receiver identifier that could be either an accountID or policyID, and check accordingly against the report's invoiceReceiver.

    2. IOURequestStepConfirmation.tsx:232-238 — When the receiver is a business type, extract the policyID from the invoiceReceiver and pass it as the receiverID to useParticipantsInvoiceReport (which already supports B2B matching at lines 58-62).

    3. getSendInvoiceInformation in SendInvoice.ts:603-606 — Same fix: correctly resolve the receiver for B2B cases so the existing invoice room is recognized and receiverInvoiceRoomID is sent instead of an empty receiverEmail.

    4. buildOptimisticChatReport in ReportUtils.ts:7842-7848 — Address the TODO: when creating an optimistic invoice chat for a B2B receiver, set invoiceReceiver with type: 'policy' and the receiver's policyID.

    What alternative solutions did you explore? (Optional)

    An alternative would be to handle this entirely in the confirmation step by detecting B2B invoice rooms early and passing the existing room's reportID directly as invoiceChatReport to sendInvoice(), bypassing the receiver matching logic. However, this would leave the underlying matching functions broken for B2B, which could cause issues in other flows that use doesReportReceiverMatchParticipant.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  7. shubham1206agra commented on Feb 18, 2026

    @shubham1206agra
    Contributor

    @MelvinBot How about we revert #75262 as the problem it is trying to solve was fixed in another PR?

  8. MelvinBot commented on Feb 18, 2026

    @MelvinBot
    Contributor

    @shubham1206agra I investigated the revert suggestion for PR #75262 in depth. Here's my assessment:

    Would reverting fix B2B invoice sending?

    Yes, reverting would fix B2B invoice sending because removing doesReportReceiverMatchParticipant would allow the existing B2B invoice room report to pass through to sendInvoice() unblocked.

    Would reverting regress issue #73640?

    Yes, it would. doesReportReceiverMatchParticipant is the only mechanism that prevents the offline recipient change bug. Without it, the code at IOURequestStepConfirmation.tsx:1091-1092 would revert to:

    const invoiceChatReport = !isEmptyObject(report) && report?.reportID ? report : existingInvoiceReport;
    

    Here, report (from the URL/route) always wins if non-empty — even when the user changed the recipient offline. The useParticipantsInvoiceReport hook result would never be consulted.

    I could not find evidence that any other PR independently fixed issue #73640's offline recipient change scenario. Could you share which PR you're referring to? That would help determine if the revert is safe.

    Recommended alternative: Fix doesReportReceiverMatchParticipant to support B2B

    Rather than reverting, the better approach is to extend the existing logic to handle both receiver types. As described in my earlier analysis, the core changes needed are:

    1. doesReportReceiverMatchParticipant (ReportUtils.ts:1720-1722) — Add B2B matching by policyID alongside the existing accountID check
    2. IOURequestStepConfirmation.tsx:232-238 — Pass the receiver's policyID (not 0) to useParticipantsInvoiceReport for B2B cases
    3. getSendInvoiceInformation (SendInvoice.ts:603-606) — Same B2B-aware receiver resolution

    This preserves the offline recipient change protection while fixing B2B invoices.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  9. shubham1206agra commented on Feb 18, 2026

    @shubham1206agra
    Contributor

    @MelvinBot This PR #79285 solved that bug. See the line selectedReportID.current = firstParticipantReportID && isInvoiceRoomWithID(firstParticipantReportID) ? firstParticipantReportID : generateReportID();, which creates a new reportID if the invoice room is not present.

  10. 13 remaining items

  11. changed the title [-]Dev: Unable to send invoice from business invoice room[/-] [+][Due for payment 2026-03-06] Dev: Unable to send invoice from business invoice room[/+] on Feb 27, 2026
  12. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  13. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.26-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-03-06. 🎊

    For reference, here are some details about the assignees on this issue:

  14. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    @shubham1206agra @kadiealexander The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. kadiealexander commented on Mar 6, 2026

    @kadiealexander
    Contributor

    @shubham1206agra can you please complete the checklist?

  16. shubham1206agra commented on Mar 6, 2026

    @shubham1206agra
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: fixed changing receipient of invoice offline #75262 (comment)

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

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

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/609062

    Regression Test Proposal

    Test:

    1. Open any B2B Invoice room
    2. Try to send an invoice for any amount
    3. Verify that no error is displayed, and the invoice is sent successfully

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-80ee-af18-9915-a858c5e839d4
  17. melvin-bot commented on Mar 6, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@kadiealexander)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  18. garrettmknight commented on Apr 2, 2026

    @garrettmknight
    Contributor

    $250 approved for @shubham1206agra

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 contributorHelp WantedApply this label when an issue is open to proposals by contributorsMelvin TriageAutomatic AI Analysis of an issue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions