Repository navigation
Description
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:
- Open any B2B Invoice room
- Try to send invoice of any amount
- 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
Issue Owner
Current Issue Owner: @kadiealexanderMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Feb 16, 2026
Current assignee @shubham1206agra is eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Feb 16, 2026
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.melvin-bot commentedon Feb 16, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
MelvinBot commentedon Feb 18, 2026
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 anaccountID(the individual receiver case).The failure chain:
doesReportReceiverMatchParticipant()(ReportUtils.ts:1720-1722) only checks'accountID' in report.invoiceReceiver. For B2B rooms where the receiver haspolicyIDinstead, this always returnsfalse— so the existing B2B invoice room is never recognized as a valid match.In
IOURequestStepConfirmation.tsx:232-234,receiverAccountIDdefaults to0(since the B2B receiver has noaccountID), andreceiverParticipantAccountIDbecomesundefined.useParticipantsInvoiceReport(useParticipantsInvoiceReport.ts:49-67) is called withreceiverID=0— it supports B2B matching bypolicyID, but receives the wrong input so finds nothing.Both matching paths fail, so
invoiceChatReportisnulland the code falls through to create a new optimistic chat report.In
getSendInvoiceInformation()(SendInvoice.ts:801), sinceinvoiceChatReportis undefined, it sendsreceiverEmail: ''(empty string) instead ofreceiverInvoiceRoomID. This is becausegetPersonalDetailsForAccountID(0)returns{}(since!0is truthy in JS), soreceiver.loginisundefined.The backend rejects the request (empty
receiverEmail, noreceiverInvoiceRoomID), triggering the pre-definedfailureDatawhich setserrorFields.createChatwith 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 hardcodesinvoiceReceiveras{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 byaccountID) in several locations:doesReportReceiverMatchParticipantinReportUtils.ts:1720-1722— Extend to also match business receivers bypolicyID. The function should accept a receiver identifier that could be either anaccountIDorpolicyID, and check accordingly against the report'sinvoiceReceiver.IOURequestStepConfirmation.tsx:232-238— When the receiver is a business type, extract thepolicyIDfrom theinvoiceReceiverand pass it as thereceiverIDtouseParticipantsInvoiceReport(which already supports B2B matching at lines 58-62).getSendInvoiceInformationinSendInvoice.ts:603-606— Same fix: correctly resolve the receiver for B2B cases so the existing invoice room is recognized andreceiverInvoiceRoomIDis sent instead of an emptyreceiverEmail.buildOptimisticChatReportinReportUtils.ts:7842-7848— Address the TODO: when creating an optimistic invoice chat for a B2B receiver, setinvoiceReceiverwithtype: 'policy'and the receiver'spolicyID.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
reportIDdirectly asinvoiceChatReporttosendInvoice(), bypassing the receiver matching logic. However, this would leave the underlying matching functions broken for B2B, which could cause issues in other flows that usedoesReportReceiverMatchParticipant.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.shubham1206agra commentedon Feb 18, 2026
@MelvinBot How about we revert #75262 as the problem it is trying to solve was fixed in another PR?
MelvinBot commentedon Feb 18, 2026
@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
doesReportReceiverMatchParticipantwould allow the existing B2B invoice roomreportto pass through tosendInvoice()unblocked.Would reverting regress issue #73640?
Yes, it would.
doesReportReceiverMatchParticipantis the only mechanism that prevents the offline recipient change bug. Without it, the code atIOURequestStepConfirmation.tsx:1091-1092would revert to:Here,
report(from the URL/route) always wins if non-empty — even when the user changed the recipient offline. TheuseParticipantsInvoiceReporthook 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
doesReportReceiverMatchParticipantto support B2BRather 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:
doesReportReceiverMatchParticipant(ReportUtils.ts:1720-1722) — Add B2B matching bypolicyIDalongside the existingaccountIDcheckIOURequestStepConfirmation.tsx:232-238— Pass the receiver'spolicyID(not0) touseParticipantsInvoiceReportfor B2B casesgetSendInvoiceInformation(SendInvoice.ts:603-606) — Same B2B-aware receiver resolutionThis preserves the offline recipient change protection while fixing B2B invoices.
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.shubham1206agra commentedon Feb 18, 2026
@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.13 remaining items
[-]Dev: Unable to send invoice from business invoice room[/-][+][Due for payment 2026-03-06] Dev: Unable to send invoice from business invoice room[/+]melvin-bot commentedon Feb 27, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Feb 27, 2026
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:
melvin-bot commentedon Feb 27, 2026
@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]
kadiealexander commentedon Mar 6, 2026
@shubham1206agra can you please complete the checklist?
shubham1206agra commentedon Mar 6, 2026
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:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-80ee-af18-9915-a858c5e839d4melvin-bot commentedon Mar 6, 2026
Payment Summary
Upwork Job
BugZero Checklist (@kadiealexander)
garrettmknight commentedon Apr 2, 2026
$250 approved for @shubham1206agra