You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-08-07] [$250] Invoice - Infinite loading when creating invoice offline then viewing it online #96925
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
The offline invoice only ever exists as optimistic Onyx data, and when the queued request fails on going online, the app has no path to surface or dismiss that failure — so the report gets stuck loading and vanishes on cache clear.
Walking the flow:
Offline:sendInvoice() builds an optimistic invoice report, transaction and report actions, then queues the SEND_INVOICE write. The optimistic report is tagged with pendingFields.createChat and carries a non-zero total (SendInvoice.ts:153-171, ReportUtils.ts:6905-6926).
Online: the queued request is rejected by the backend (recipient is not a WS member and/or the company website is invalid). The failureData only annotates the optimistic report/transaction/actions with errors / errorFields.createChat — it never deletes them (SendInvoice.ts:419-478). The report was never persisted server-side, so it's now a phantom that only lives locally.
Infinite loading: opening the invoice renders the report-actions skeleton via shouldWaitForTransactions(). For an online invoice report with an empty transaction list it stays "loading" because report.total !== 0, and its only escape hatch checks pendingFields.createReport === ADD — but invoices use createChat, so the escape never fires (MoneyRequestReportUtils.ts:145-164, gated at ReportActions.tsx:56-80).
No way out: the ReportScreen error/dismiss banner only reads errorFields.createReport, but the invoice's error is on errorFields.createChat, so no red-brick-road banner appears and removeFailedReport is never reachable (ReportScreen.tsx:94-106).
Disappears after cache clear: the invoice is purely optimistic Onyx state, so wiping the cache removes it entirely and nothing server-side backs it up.
What changes do you think we should make in order to solve the problem?
Make the failed offline invoice visible and dismissible instead of silently stuck:
Surface the errorFields.createChat (and transaction errors) on the report screen so the user sees the "red brick road" error and can dismiss it — i.e. include createChat in the reportPendingAction / reportErrors selectors in ReportScreen.tsx:94-106 (mirroring how createReport is handled), so dismissing it calls removeFailedReport.
Fix the skeleton escape hatch in shouldWaitForTransactions() so an invoice report with a pending/errored createChat (or one carrying errors) does not render the infinite loading skeleton.
What alternative solutions did you explore? (Optional)
Have SEND_INVOICE's failureData clean up the optimistic report/transaction/actions on hard-failure (as removeFailedReport does) so no phantom remains — though keeping the error visible so the user knows the invoice failed is preferable to silently removing it.
Confidence & open questions
Confidence: medium. The "disappears after cache clear" and "no dismiss path" mechanisms are well supported by the code above. The exact infinite-loading branch has one caveat worth verifying at runtime: a focused trace suggested the optimistic transaction may persist attached to the invoice report after failure (making transactions.length === 1), which would bypass the skeleton. Confirming with logs whether the transaction/report-actions are actually empty at skeleton time — and the exact backend rejection jsonCode for a non-WS-member recipient / invalid website — would pin this down. The backend rejection reason itself lives in a backend repo, but the user-facing bug (stuck + no error surfaced) is an App-side handling gap and is fixable in App.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/96925) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
🚨 Edited by proposal-police: This proposal was edited at 2026-07-24 06:03:39 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
An invoice created offline shows an infinite loading skeleton when the user goes online and opens it, instead of rendering the (failed) invoice with its error state. After clearing cache the invoice vanishes, because the server never actually created it.
What is the root cause of that problem?
SendInvoice is the only money-request creation flow whose Onyx data never settles the "optimistic / never-loaded" bookkeeping, so an offline-created invoice gets permanently stuck in a loading state that only resolves offline — the exact state this repro views online.
buildOnyxDataForInvoice marks all three optimistic reports (invoice room, invoice report, transaction thread) with reportMetadata.isOptimisticReport: true:
. SendInvoice.ts has zero writes to that key, so every invoice report starts (and stays) at the default isLoadingInitialReportActions: true / hasOnceLoadedReportActions: false (
. Where OpenReport does fire (the invoice report itself), it 404s (the server rejected the create) and its failureData clears only isLoadingInitialReportActions, never hasOnceLoadedReportActions:
). This is the same regression family as #96925's sibling #90293 ("Invoice report loads infinitely when sent offline"): its fix #90323 added !isOffline escapes to these gates, which cures the offline view but by design does nothing once the user is back online — this issue's exact repro.
This explains every symptom: only invoices (expenses get the sibling stamp), only after offline creation (online success clears the flags via successData), infinite loading rather than an error (the gates never resolve, so the already-written errorFields.createChat is never rendered), and disappearance after cache clear (the report exists only in local optimistic data).
What changes do you think we should make in order to solve the problem?
Bring buildOnyxDataForInvoice to parity with the expense flow: in its optimisticData, stamp the loading state for the three reports it creates, mirroring MoneyRequestBuilder.ts#L668-L674:
The optimistic data written by SendInvoice is already the complete local truth for these reports, so "loaded" is correct from the moment of creation — exactly the invariant expenses already rely on. Every gate above then resolves, and after the rejected SendInvoice the room renders with its errorFields.createChat RBR error, matching the expected result. Regression safety: this key is RAM-only and per-reportID, the stamp matches the long-shipped expense behavior, and success/failure flows for existing invoice rooms are untouched.
Why the obvious spot-fix fails: relaxing the fetchReport skip-gate (ReportFetchHandler.tsx#L156-L159) to force an OpenReport doesn't work — while the create is still queued, OpenReport on an optimistic ID 404s and merges errorFields.notFound into a perfectly healthy pending room (the gate exists precisely to prevent that), and even after it fires, its failureData still never sets hasOnceLoadedReportActions (Report/index.ts#L1627-L1632), so shouldWaitForTransactions-class gates keep waiting on a fetch that can never succeed for a report the server refused to create. The stamp removes the dependency on any network call instead of adding one that must fail.
Secondary (optional): mirror the three successDataisOptimisticReport: false resets into failureData so a room whose create was rejected stops being treated as "creation still pending" by ReportFetchHandler and becomes re-fetchable/dismissable consistently.
What alternative solutions did you explore? (Optional)
Add more !isOffline/error escapes to the individual skeleton gates (the #90323 approach again) — incomplete: there are at least four independent gate sites across chat view, report view, and thread navigation; patching them one by one leaves the underlying "never loaded" state to resurface in the next consumer.
Clear isLoadingInitialReportActions in SendInvoicefailureData only — fixes the post-failure view but not the window while the request is in flight online, and leaves hasOnceLoadedReportActions false, so hasLoadedReportActions-based gates (thread deletion checks, legacy-thread creation) still misbehave.
Backend accepts/creates the invoice and reports the website error afterwards — out of scope for this repo; the App must handle a rejected queued create gracefully regardless.
I found that the failed invoice remains an optimistic report with a non-zero total. buildOptimisticInvoiceReport() assigns that total before the offline request is sent:
However, shouldWaitForTransactions() treats every online invoice with no transactions and a non-zero report total as still loading. It does not account for the terminal errorFields.createChat state:
Consequently, MoneyRequestReportView returns the loading skeleton before reaching the OfflineWithFeedback component that would display the creation error:
The history shows that the non-zero-total check was introduced to avoid briefly rendering an empty report while transactions are loading, but no terminal-error exception was added:
This allows MoneyRequestReportView to render its existing OfflineWithFeedback error row instead of an endless skeleton, so the user can see and dismiss the failed invoice.
Successful reports are unaffected because they do not have errorFields.createChat; the existing loading protection for non-zero reports and deferred writes remains intact. The same guard also correctly handles failed optimistic expense reports that use the same creation-error field.
I would add unit coverage for shouldWaitForTransactions() confirming that:
A non-zero invoice with no transactions still waits while loading normally.
The same invoice stops waiting after errorFields.createChat is set.
Existing offline, transaction-thread, and successful-report behavior remains unchanged.
What alternative solutions did you explore? (Optional)
I considered resetting the optimistic report’s total on failure. That would happen to bypass the loading condition, but it would mutate valid invoice data merely to control rendering and couple the failure handler to this UI heuristic. Checking the existing terminal creation-error state directly in shouldWaitForTransactions() is smaller and preserves the failed invoice’s details.
Please re-state the problem that we are trying to solve in this issue.
An invoice created while offline never finishes loading once the user comes back online and opens it. The invoice chat shows an endless loading skeleton instead of either the invoice content or the error that caused the creation to fail, and clearing the cache makes the invoice vanish entirely.
What is the root cause of that problem?
Creating an invoice offline builds three optimistic reports (the invoice room, the invoice report and the transaction thread) and flags each of them in Onyx with REPORT_METADATA.isOptimisticReport = true. For the invoice room this happens only when the room is new, which is exactly the reported scenario (the receiver is not a member of the workspace, so a brand new invoice room is created):
In the repro the request deliberately fails on reconnect (the invalid company website is rejected), so failureData runs instead. It records the error on the reports and on the transaction, but it never clears isOptimisticReport, so the invoice room stays flagged as optimistic forever:
The invoice room is a report of type CHAT that is not a policy expense chat, so when the user opens it, fetchReport in ReportFetchHandler takes its early return and never calls openReport:
The problem is that this bail-out path leaves the report permanently marked as loading. The effect just above it unconditionally sets isLoadingInitialReportActions back to true for any report that has not yet successfully loaded its actions:
Nothing will ever flip that flag back to false for this report. The success and failure handlers of openReport do, but openReport is precisely what we just decided to skip. The only other writers that clear it are the handlers of createGroupChat, which never run for an invoice room, and a hook that clears it when deep-linking to a message while offline, which requires a linked report action ID in the route. So isLoadingInitialReportActions stays true with hasOnceLoadedReportActions stuck at false, which keeps the report-actions skeleton on screen and also keeps ReportNotFoundGuard in its "still loading" branch, so the screen can never settle on content or on an error either:
While the user is offline the loading flag is ignored by these gates, which is why the invoice looks fine offline and only hangs after going back online. And because the whole thing only ever existed in local Onyx data, clearing the cache removes it — hence the disappearing invoice.
What changes do you think we should make in order to solve the problem?
In fetchReport in src/pages/inbox/ReportFetchHandler.tsx, when we take the early return for an optimistic chat report, we should also mark the initial report-actions load as finished for that report before returning, by calling the existing updateLoadingInitialReportAction helper with false for the report ID from the route.
The reasoning is that this branch is a deliberate decision that there is nothing to fetch from the server for this report — its content is purely local. Leaving the loading flag asserted claims a fetch is in flight when none will ever happen, which is what produces the infinite skeleton. Resolving the flag on the same path where we decide not to fetch keeps the loading state honest. There is already precedent for exactly this in the codebase: the deep-link-while-offline hook clears the same flag on another path where the initial actions are known to be available locally and no fetch is going to resolve it:
// When we linked to message - we do not need to wait for initial actions - they already exists
if(!reportActionIDFromRoute||!isOffline){
return;
}
updateLoadingInitialReportAction(reportID);
},[isOffline,reportID,reportActionIDFromRoute]);
With that change the invoice room renders its locally available content, and the red brick road error that SendInvoice's failure handling already writes onto the report and the transaction becomes visible, which matches the expected result in the issue: no infinite loading, and the error is surfaced instead.
This is scoped to the branch we already short-circuit, so reports that genuinely have a pending server fetch are unaffected, and the fix is not invoice specific — any chat report that is still flagged optimistic and therefore never fetched gets the same correct behaviour.
What alternative solutions did you explore? (Optional)
I also looked at clearing isOptimisticReport inside SendInvoice's failureData, mirroring what successData does for the three reports. I decided against it because clearing the flag would let openReport run against a report that was never created on the server, which returns not found and would replace the invoice with a "not here" page rather than showing the creation error the issue asks for. It would also be inconsistent with the rest of the codebase, where isOptimisticReport is only ever reset in success handlers.
I also considered changing the effect that re-asserts isLoadingInitialReportActions so it skips reports that will never be fetched, but that would mean duplicating the optimistic-report condition in a second place and would risk regressing the stale-flag fix that effect was added for.
changed the title [-]Invoice - Infinite loading when creating invoice offline then viewing it online[/-][+][$250] Invoice - Infinite loading when creating invoice offline then viewing it online[/+]on Jul 24, 2026
[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: N/A
[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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Create an invoice with a valid user who is not a member of the workspace, and enter an invalid website address in the company address (e.g. www.none.com).
Go online.
Open the invoice created in step 3.
Verify no infinite loading skeleton appears — the invoice renders and its red-brick-road creation error is visible.
Verify the created invoice is dismissable (dismiss-and-delete of the failed local invoice still works).
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
Activity
applause-bot commentedon Jul 24, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/488523f350c59740e88b08be7c4dd97e8060d2630d30231eb6708cf522078816
MelvinBot commentedon Jul 24, 2026
Proposal
What is the root cause of that problem?
The offline invoice only ever exists as optimistic Onyx data, and when the queued request fails on going online, the app has no path to surface or dismiss that failure — so the report gets stuck loading and vanishes on cache clear.
Walking the flow:
Offline:
sendInvoice()builds an optimistic invoice report, transaction and report actions, then queues theSEND_INVOICEwrite. The optimistic report is tagged withpendingFields.createChatand carries a non-zerototal(SendInvoice.ts:153-171,ReportUtils.ts:6905-6926).Online: the queued request is rejected by the backend (recipient is not a WS member and/or the company website is invalid). The
failureDataonly annotates the optimistic report/transaction/actions witherrors/errorFields.createChat— it never deletes them (SendInvoice.ts:419-478). The report was never persisted server-side, so it's now a phantom that only lives locally.Infinite loading: opening the invoice renders the report-actions skeleton via
shouldWaitForTransactions(). For an online invoice report with an empty transaction list it stays "loading" becausereport.total !== 0, and its only escape hatch checkspendingFields.createReport === ADD— but invoices usecreateChat, so the escape never fires (MoneyRequestReportUtils.ts:145-164, gated atReportActions.tsx:56-80).No way out: the ReportScreen error/dismiss banner only reads
errorFields.createReport, but the invoice's error is onerrorFields.createChat, so no red-brick-road banner appears andremoveFailedReportis never reachable (ReportScreen.tsx:94-106).Disappears after cache clear: the invoice is purely optimistic Onyx state, so wiping the cache removes it entirely and nothing server-side backs it up.
What changes do you think we should make in order to solve the problem?
Make the failed offline invoice visible and dismissible instead of silently stuck:
errorFields.createChat(and transactionerrors) on the report screen so the user sees the "red brick road" error and can dismiss it — i.e. includecreateChatin thereportPendingAction/reportErrorsselectors inReportScreen.tsx:94-106(mirroring howcreateReportis handled), so dismissing it callsremoveFailedReport.shouldWaitForTransactions()so an invoice report with a pending/erroredcreateChat(or one carrying errors) does not render the infinite loading skeleton.What alternative solutions did you explore? (Optional)
Have
SEND_INVOICE'sfailureDataclean up the optimistic report/transaction/actions on hard-failure (asremoveFailedReportdoes) so no phantom remains — though keeping the error visible so the user knows the invoice failed is preferable to silently removing it.Confidence & open questions
Confidence: medium. The "disappears after cache clear" and "no dismiss path" mechanisms are well supported by the code above. The exact infinite-loading branch has one caveat worth verifying at runtime: a focused trace suggested the optimistic transaction may persist attached to the invoice report after failure (making
transactions.length === 1), which would bypass the skeleton. Confirming with logs whether the transaction/report-actions are actually empty at skeleton time — and the exact backend rejectionjsonCodefor a non-WS-member recipient / invalid website — would pin this down. The backend rejection reason itself lives in a backend repo, but the user-facing bug (stuck + no error surfaced) is an App-side handling gap and is fixable in App.Possibly related
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/96925)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
ahmdshrif commentedon Jul 24, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-07-24 06:03:39 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
An invoice created offline shows an infinite loading skeleton when the user goes online and opens it, instead of rendering the (failed) invoice with its error state. After clearing cache the invoice vanishes, because the server never actually created it.
What is the root cause of that problem?
SendInvoiceis the only money-request creation flow whose Onyx data never settles the "optimistic / never-loaded" bookkeeping, so an offline-created invoice gets permanently stuck in a loading state that only resolves offline — the exact state this repro views online.buildOnyxDataForInvoicemarks all three optimistic reports (invoice room, invoice report, transaction thread) withreportMetadata.isOptimisticReport: true:App/src/libs/actions/IOU/SendInvoice.ts
Lines 165 to 171 in 2b3f4c0
App/src/libs/actions/IOU/SendInvoice.ts
Lines 206 to 212 in 2b3f4c0
App/src/libs/actions/IOU/SendInvoice.ts
Lines 250 to 258 in 2b3f4c0
successData(App/src/libs/actions/IOU/SendInvoice.ts
Lines 318 to 324 in 2b3f4c0
failureDatablock contains no metadata or loading-state reset (App/src/libs/actions/IOU/SendInvoice.ts
Lines 419 to 533 in 2b3f4c0
SendInvoiceis rejected on reconnect (here: the invalid company website), the reports stay flagged optimistic forever.hasOnceLoadedReportActions: trueinRAM_ONLY_REPORT_LOADING_STATE:App/src/libs/actions/IOU/MoneyRequestBuilder.ts
Lines 668 to 674 in 2b3f4c0
SendInvoice.tshas zero writes to that key, so every invoice report starts (and stays) at the defaultisLoadingInitialReportActions: true/hasOnceLoadedReportActions: false(App/src/pages/inbox/ReportFetchHandler.tsx
Lines 67 to 74 in 2b3f4c0
OpenReportcall — but for the optimistic invoice room,fetchReportdeliberately never dispatches one:App/src/pages/inbox/ReportFetchHandler.tsx
Lines 156 to 159 in 2b3f4c0
truewhilehasOnceLoadedReportActionsis false:App/src/pages/inbox/ReportFetchHandler.tsx
Lines 340 to 345 in 2b3f4c0
OpenReportdoes fire (the invoice report itself), it 404s (the server rejected the create) and itsfailureDataclears onlyisLoadingInitialReportActions, neverhasOnceLoadedReportActions:App/src/libs/actions/Report/index.ts
Lines 1627 to 1632 in 2b3f4c0
shouldWaitForTransactions/hasLoadedReportActions(App/src/libs/MoneyRequestReportUtils.ts
Lines 145 to 163 in 2b3f4c0
App/src/libs/TransactionNavigationUtils.ts
Lines 17 to 22 in 2b3f4c0
App/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx
Line 171 in 2b3f4c0
App/src/pages/inbox/report/ReportActionsListContext.tsx
Lines 71 to 111 in 2b3f4c0
#96925's sibling#90293("Invoice report loads infinitely when sent offline"): its fix#90323added!isOfflineescapes to these gates, which cures the offline view but by design does nothing once the user is back online — this issue's exact repro.This explains every symptom: only invoices (expenses get the sibling stamp), only after offline creation (online success clears the flags via
successData), infinite loading rather than an error (the gates never resolve, so the already-writtenerrorFields.createChatis never rendered), and disappearance after cache clear (the report exists only in local optimistic data).What changes do you think we should make in order to solve the problem?
Bring
buildOnyxDataForInvoiceto parity with the expense flow: in itsoptimisticData, stamp the loading state for the three reports it creates, mirroringMoneyRequestBuilder.ts#L668-L674:The optimistic data written by
SendInvoiceis already the complete local truth for these reports, so "loaded" is correct from the moment of creation — exactly the invariant expenses already rely on. Every gate above then resolves, and after the rejectedSendInvoicethe room renders with itserrorFields.createChatRBR error, matching the expected result. Regression safety: this key is RAM-only and per-reportID, the stamp matches the long-shipped expense behavior, and success/failure flows for existing invoice rooms are untouched.Why the obvious spot-fix fails: relaxing the
fetchReportskip-gate (ReportFetchHandler.tsx#L156-L159) to force anOpenReportdoesn't work — while the create is still queued,OpenReporton an optimistic ID 404s and mergeserrorFields.notFoundinto a perfectly healthy pending room (the gate exists precisely to prevent that), and even after it fires, itsfailureDatastill never setshasOnceLoadedReportActions(Report/index.ts#L1627-L1632), soshouldWaitForTransactions-class gates keep waiting on a fetch that can never succeed for a report the server refused to create. The stamp removes the dependency on any network call instead of adding one that must fail.Secondary (optional): mirror the three
successDataisOptimisticReport: falseresets intofailureDataso a room whose create was rejected stops being treated as "creation still pending" byReportFetchHandlerand becomes re-fetchable/dismissable consistently.What alternative solutions did you explore? (Optional)
!isOffline/error escapes to the individual skeleton gates (the#90323approach again) — incomplete: there are at least four independent gate sites across chat view, report view, and thread navigation; patching them one by one leaves the underlying "never loaded" state to resurface in the next consumer.isLoadingInitialReportActionsinSendInvoicefailureDataonly — fixes the post-failure view but not the window while the request is in flight online, and leaveshasOnceLoadedReportActionsfalse, sohasLoadedReportActions-based gates (thread deletion checks, legacy-thread creation) still misbehave.mukhrr commentedon Jul 24, 2026
Proposal
What is the root cause of that problem?
I found that the failed invoice remains an optimistic report with a non-zero
total.buildOptimisticInvoiceReport()assigns that total before the offline request is sent:App/src/libs/ReportUtils.ts
Lines 6894 to 6918 in 2b3f4c0
When the deferred
SendInvoicerequest fails validation, its failure data clears the pending state and adds acreateChaterror to the invoice report:App/src/libs/actions/IOU/SendInvoice.ts
Lines 439 to 465 in 2b3f4c0
However,
shouldWaitForTransactions()treats every online invoice with no transactions and a non-zero report total as still loading. It does not account for the terminalerrorFields.createChatstate:App/src/libs/MoneyRequestReportUtils.ts
Lines 145 to 163 in 2b3f4c0
Consequently,
MoneyRequestReportViewreturns the loading skeleton before reaching theOfflineWithFeedbackcomponent that would display the creation error:App/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx
Lines 167 to 174 in 2b3f4c0
App/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx
Lines 215 to 225 in 2b3f4c0
App/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx
Lines 249 to 266 in 2b3f4c0
The history shows that the non-zero-total check was introduced to avoid briefly rendering an empty report while transactions are loading, but no terminal-error exception was added:
App/src/libs/MoneyRequestReportUtils.ts
Lines 136 to 149 in efa7947
What changes do you think we should make in order to solve the problem?
I think we should update
shouldWaitForTransactions()to stop waiting when the report has acreateChaterror:return ( (isMoneyRequestReport(report) || isInvoiceReport(report)) && (!isTransactionDataReady || isStillLoadingData) && + !report?.errorFields?.createChat && !isTransactionThreadView &&This allows
MoneyRequestReportViewto render its existingOfflineWithFeedbackerror row instead of an endless skeleton, so the user can see and dismiss the failed invoice.Successful reports are unaffected because they do not have
errorFields.createChat; the existing loading protection for non-zero reports and deferred writes remains intact. The same guard also correctly handles failed optimistic expense reports that use the same creation-error field.I would add unit coverage for
shouldWaitForTransactions()confirming that:errorFields.createChatis set.What alternative solutions did you explore? (Optional)
I considered resetting the optimistic report’s
totalon failure. That would happen to bypass the loading condition, but it would mutate valid invoice data merely to control rendering and couple the failure handler to this UI heuristic. Checking the existing terminal creation-error state directly inshouldWaitForTransactions()is smaller and preserves the failed invoice’s details.melvin-bot commentedon Jul 24, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (
External)wildan-m commentedon Jul 24, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
An invoice created while offline never finishes loading once the user comes back online and opens it. The invoice chat shows an endless loading skeleton instead of either the invoice content or the error that caused the creation to fail, and clearing the cache makes the invoice vanish entirely.
What is the root cause of that problem?
Creating an invoice offline builds three optimistic reports (the invoice room, the invoice report and the transaction thread) and flags each of them in Onyx with
REPORT_METADATA.isOptimisticReport = true. For the invoice room this happens only when the room is new, which is exactly the reported scenario (the receiver is not a member of the workspace, so a brand new invoice room is created):App/src/libs/actions/IOU/SendInvoice.ts
Lines 239 to 258 in 6d1f663
For the invoice room that flag is cleared only when the queued
SendInvoicerequest comes back successfully:App/src/libs/actions/IOU/SendInvoice.ts
Lines 396 to 415 in 6d1f663
In the repro the request deliberately fails on reconnect (the invalid company website is rejected), so
failureDataruns instead. It records the error on the reports and on the transaction, but it never clearsisOptimisticReport, so the invoice room stays flagged as optimistic forever:App/src/libs/actions/IOU/SendInvoice.ts
Lines 419 to 466 in 6d1f663
The invoice room is a report of type
CHATthat is not a policy expense chat, so when the user opens it,fetchReportinReportFetchHandlertakes its early return and never callsopenReport:App/src/pages/inbox/ReportFetchHandler.tsx
Lines 156 to 159 in 6d1f663
The problem is that this bail-out path leaves the report permanently marked as loading. The effect just above it unconditionally sets
isLoadingInitialReportActionsback totruefor any report that has not yet successfully loaded its actions:App/src/pages/inbox/ReportFetchHandler.tsx
Lines 340 to 345 in 6d1f663
Nothing will ever flip that flag back to
falsefor this report. The success and failure handlers ofopenReportdo, butopenReportis precisely what we just decided to skip. The only other writers that clear it are the handlers ofcreateGroupChat, which never run for an invoice room, and a hook that clears it when deep-linking to a message while offline, which requires a linked report action ID in the route. SoisLoadingInitialReportActionsstaystruewithhasOnceLoadedReportActionsstuck atfalse, which keeps the report-actions skeleton on screen and also keepsReportNotFoundGuardin its "still loading" branch, so the screen can never settle on content or on an error either:App/src/pages/inbox/ReportNotFoundGuard.tsx
Line 55 in 6d1f663
While the user is offline the loading flag is ignored by these gates, which is why the invoice looks fine offline and only hangs after going back online. And because the whole thing only ever existed in local Onyx data, clearing the cache removes it — hence the disappearing invoice.
What changes do you think we should make in order to solve the problem?
In
fetchReportinsrc/pages/inbox/ReportFetchHandler.tsx, when we take the early return for an optimistic chat report, we should also mark the initial report-actions load as finished for that report before returning, by calling the existingupdateLoadingInitialReportActionhelper withfalsefor the report ID from the route.The reasoning is that this branch is a deliberate decision that there is nothing to fetch from the server for this report — its content is purely local. Leaving the loading flag asserted claims a fetch is in flight when none will ever happen, which is what produces the infinite skeleton. Resolving the flag on the same path where we decide not to fetch keeps the loading state honest. There is already precedent for exactly this in the codebase: the deep-link-while-offline hook clears the same flag on another path where the initial actions are known to be available locally and no fetch is going to resolve it:
App/src/hooks/useLinkedMessageOfflineLoading.ts
Lines 23 to 29 in 6d1f663
With that change the invoice room renders its locally available content, and the red brick road error that
SendInvoice's failure handling already writes onto the report and the transaction becomes visible, which matches the expected result in the issue: no infinite loading, and the error is surfaced instead.This is scoped to the branch we already short-circuit, so reports that genuinely have a pending server fetch are unaffected, and the fix is not invoice specific — any chat report that is still flagged optimistic and therefore never fetched gets the same correct behaviour.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/96925-optimistic-chat-loading-flag?expand=1
What alternative solutions did you explore? (Optional)
I also looked at clearing
isOptimisticReportinsideSendInvoice'sfailureData, mirroring whatsuccessDatadoes for the three reports. I decided against it because clearing the flag would letopenReportrun against a report that was never created on the server, which returns not found and would replace the invoice with a "not here" page rather than showing the creation error the issue asks for. It would also be inconsistent with the rest of the codebase, whereisOptimisticReportis only ever reset in success handlers.I also considered changing the effect that re-asserts
isLoadingInitialReportActionsso it skips reports that will never be fetched, but that would mean duplicating the optimistic-report condition in a second place and would risk regressing the stale-flag fix that effect was added for.[-]Invoice - Infinite loading when creating invoice offline then viewing it online[/-][+][$250] Invoice - Infinite loading when creating invoice offline then viewing it online[/+]melvin-bot commentedon Jul 24, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022080532865576867228
godzillaxbox19982014-lgtm commentedon Jul 24, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
49 remaining items
daledah commentedon Jul 31, 2026
BugZero 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: N/A
[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.
[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/669708
Regression Test Proposal
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-dd4c-a098-a5aa-25ec4eb16074melvin-bot commentedon Aug 6, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Aug 6, 2026
Payment Summary
Resolving PRs:
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Aug 8, 2026
Payment Summary
Contributor: @dilshodmackbook-sketch paid $250 via Upwork
Contributor+: @daledah due $250 via NewDot
@dilshodmackbook-sketch can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022080532865576867228
David-2002065 commentedon Aug 8, 2026
@mallenexpensify accepted thanks.
mallenexpensify commentedon Aug 11, 2026
@dilshodmackbook-sketch paid, summary updated above. Thx.
quinthar commentedon Sep 26, 2026
Approved $250 to @daledah