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-12] [$250] No error is displayed when creating a chat with failing network request #95864
Version Number: v9.4.33-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from TestRail:https://github.com/Expensify/Expensify/issues/641717 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team
Action Performed:
Enable "Simulate failing network requests"
Go to Inbox
Press the global create button > Start chat
Start a chat with a user you never chatted with before
Expected Result:
The chat creation should fail and an error should be shown
Actual Result:
App turns to offline mode and no error is displayed when creating a chat with "Simulate failing network requests"
Workaround:
N/A
Platforms:
Android: App
Android: mWeb Chrome
iOS: App
iOS: mWeb Safari
iOS: mWeb Chrome
Windows: Chrome
MacOS: Chrome / Safari
Screenshots/Videos
Bug7181975_1781590392345.bandicam_2026-06-16_09-04-46-628.mp4Upwork Automation - Do Not Edit
Two things combine here — one is arguably by-design, the other is a real gap:
1. "Simulate failing network requests" gets converted into offline mode. The dev tool only sets a shouldFailAllRequests flag (Network.ts:16), which makes every HTTP call throw FAILED_TO_FETCH (HttpUtils.ts:111) — indistinguishable from a real outage. The FailureTracker counts these and, after 3 failures in 10s, fires a sustained-failure hard stop (FailureTracker.ts:54) that flips getIsOffline() to true (NetworkState.ts:36). That is why the app "turns to offline mode."
2. New-chat creation is an optimistic write with no error path. Starting a chat with a new user calls openReport with a newReportObject — a WRITE command that is queued optimistically (Report/index.ts:2326). Once the app is offline, SequentialQueue stops processing and the request just waits (SequentialQueue.ts:152) — the chat shows a normal pending/greyed state (pendingFields.createChat = ADD), which looks exactly like normal offline optimistic behavior. Critically, the failureData for a brand-new DM never sets errorFields.createChat (unlike new threads, which do set errorFields.createChatThread). So even if the request had failed while still online, no red-brick error would ever appear for a new DM.
Full data flow & evidence
navigateToAndOpenReport → getChatByParticipants empty → createAndOpenNewOptimisticChat → openReport({newReportObject}) + immediate navigate into the chat.
openReport builds optimistic data with pendingFields.createChat = ADD (Report/index.ts:1753) and calls API.paginate(WRITE, OPEN_REPORT, ...).
Request runs → HttpUtils throws FAILED_TO_FETCH → FailureTracking middleware records it (FailureTracking.ts:21).
3 failures / 10s → sustained hard stop → app offline → SequentialQueue returns early → queued OpenReport never re-runs.
New-DM failureData has no createChat error field → no error UI. Chat stays "pending."
Thresholds: COUNT: 3, WINDOW_MS: 10000 in CONST/index.ts.
What changes do you think we should make in order to solve the problem?
First, a product decision is needed: is this actually a bug, or working-as-intended? Because the FailureTracker deliberately treats failing requests as an outage, the app entering offline mode — and then queuing the new chat silently, the same as any other offline optimistic write — is the current intended offline-first behavior. Under that lens, "no error shown" is expected: the chat is queued and will be created when connectivity returns.
If product decides a new-chat creation failure should surface an error to the user, the fix is to add a createChat error path for new DMs, mirroring the existing new-thread handling: push errorFields.createChat into the failureData in the new-report branch of openReport (around Report/index.ts:1855), and render it via the report's existing red-brick-road UI. Note this alone won't change the simulate-failing repro, because the sustained-failure detection makes the app offline before the error can apply — so this only helps genuine online-but-failing responses.
What alternative solutions did you explore? (Optional)
Close as WAI if the offline-conversion behavior is intended and offline chat-queueing is the desired UX.
Confidence: Medium — the code mechanism is confirmed with file:line evidence (high), but whether the observed behavior is a bug vs. intended offline-first behavior is a product/design call the mechanism can't settle.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/95864) 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-11 00:57:23 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
With the "Simulate failing network requests" test tool enabled, starting a chat with a brand-new user (global create > Start chat) creates the chat optimistically but never surfaces any error when the server call fails. The app just drifts into offline mode and the new chat sits in a silent pending state, so the tester has no indication that creation failed.
What is the root cause of that problem?
The "Start chat" flow runs navigateToAndOpenReport in NewChatPage/index.tsx (line 396), which for a new participant calls createAndOpenNewOptimisticChat and dispatches openReport with a newReportObject. openReport builds the optimistic report with pendingFields.createChat = ADD and fires OPEN_REPORT as a persisted WRITE via API.paginate. The test tool works by making every request through HttpUtils throw FAILED_TO_FETCH (HttpUtils.ts line ~110), which is the exact same signal as a genuine offline request. When the OPEN_REPORT request is processed and throws, the SequentialQueue takes its shouldFailAllRequests branch and applies the request's failureData before dropping it:
So failureDatais applied. The real gap is what that failureData contains. For a brand-new DM, openReport's isCreatingNewReport branch only clears the loading flag and rolls back the optimistic personal details — it never writes any error onto the report:
Because no errorFields.createChat is set, the optimistic report is left with pendingFields.createChat still ADD and zero errors. getCreationReportErrors/getAllReportErrors in ReportUtils.ts therefore find nothing, so the LHN shows no red brick road and the ReportHeaderOfflineWithFeedback (which reads getReportOfflinePendingActionAndErrors) renders only a grey pending state. That is the "no error" symptom. The separate "turns offline" symptom comes from the same signal: repeated FAILED_TO_FETCH outcomes accumulate in FailureTracker and flip sustainedFailuresActive once at least 3 failures have occurred and 10 seconds have elapsed since the first one (CONST.NETWORK.SUSTAINED_FAILURE_*). That flip is mostly cosmetic, but it has one consequence that matters for this bug: once it happens, SequentialQueue stops processing (push parks new writes at SequentialQueue.ts lines 596-603 and process returns early at 152-155), so in a slow run the OPEN_REPORT write can be parked before its failureData is ever applied, and even a correct error field would not render until reconnect. A complete fix has to cover both timings, which the second change below does.
Notably the workspace-member-chat creation path already does this correctly — its failure handler sets errorFields.createChat, which is why that flow shows an error and the DM flow does not:
I reproduced this by starting a chat with a brand-new participant while all outgoing requests are set to fail, and the new DM lands in the LHN in a grey pending state with no red brick road and no error banner anywhere in the UI. Checking the underlying report data afterward, the optimistic report still carries pendingFields.createChat set to 'add' with no error fields attached at all, so the state was written correctly and nothing threw or logged an error, yet the UI gives the user no way to notice or retry the failed chat. That traces exactly to openReport's isCreatingNewReport failure handling in src/libs/actions/Report/index.ts, which on failure clears isLoadingInitialReportActions and rolls back the optimistic personal details but never sets errorFields.createChat for a plain DM, unlike the workspace-chat failure path in src/libs/actions/Policy/Policy.ts, which does push errorFields.createChat. Because nothing ever writes that error field, the report has no mechanism to signal failure and the chat just sits there looking like it's still loading.
What changes do you think we should make in order to solve the problem?
Add the missing error to openReport's failureData inside the isCreatingNewReport block (right next to the existing personal-details rollback at Report/index.ts line 1855), mirroring the established workspace-chat pattern:
The helper and translation key already exist and are used one branch above for the createChatThread case, so no new strings are needed. This makes a failed create surface a red brick road on the chat via getAllReportErrors (LHN indicator) and via getCreationReportErrors in ReportHeader, which is exactly "an error should be shown." The change is scoped by the isCreatingNewReport guard so it only fires when we actually force a new report — the re-open/existing-chat path in navigateToAndOpenReport (which calls openReport without newReportObject) is unaffected. It is also safe for genuine offline: the queue returns early and never applies failureData while offline (SequentialQueue.ts line 152), so the error only appears when the request truly reaches the server and fails, not while a chat is legitimately queued for later sync.
Second, to make the reported repro deterministic regardless of timing, guard the FailureTracking middleware so simulated failures don't feed the sustained-failure detector: skip recordFailure() while shouldFailAllRequests is enabled, via an Onyx.connectWithoutView on ONYXKEYS.NETWORK inside FailureTracking.ts, mirroring what SequentialQueue.ts lines 33-43 already do for the same flag. Without this, a run where 3+ requests fail and more than 10 seconds pass before the chat is confirmed flips the app offline first and parks the OPEN_REPORT write, so no error can render (the parked request does self-heal on tool-off via NetworkState.setFailAllRequests, but the tester sees nothing in the meantime). With the guard, the app stays online under simulation, the write always reaches the shouldFailAllRequests branch (SequentialQueue.ts lines 228-236) that applies failureData on the first failure with no retry loop, and the new errorFields.createChat renders every time. Offline simulation remains available through the separate "Force offline" tool, and the existing recovery in NetworkState.setFailAllRequests becomes a harmless backstop. The guard alone would not fix the issue, since applied failureData writes no error field today; the errorFields.createChat addition above stays the load-bearing change.
What alternative solutions did you explore? (Optional)
I considered also clearing pendingFields.createChat in failureData, but the workspace-chat precedent deliberately leaves it set so the RBR renders over the pending row, and OfflineWithFeedback already prioritizes the error state, so clearing it is unnecessary and would diverge from the existing pattern.
Please re-state the problem that we are trying to solve in this issue.
When "Simulate failing network requests" is enabled and you start a chat with a user you've never chatted with before, the chat creation request fails but no error is surfaced — the optimistic chat stays in place and the app just slips into offline mode.
What is the root cause of that problem?
With "Simulate failing network requests" on, the SequentialQueue does handle the failure correctly for persisted writes: it applies the request's failureData and drops the request instead of retrying, so an error would be shown if one were defined: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/Network/SequentialQueue.ts#L228-L235
Starting a chat with a new user goes through navigateToAndOpenReport → openReport with a newReportObject, which is a persisted OPEN_REPORT write. openReport optimistically marks the new report with pendingFields.createChat = ADD: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L1753-L1766
But its failureData only attaches a create-failure error when the report is a new thread — it never sets one for a plain new chat: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L1610-L1616
A brand-new 1:1 chat has isCreatingNewReport === true but isNewThread === false: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L1518
So when OPEN_REPORT fails, the queue applies failureData that contains no error for the report — pendingFields.createChat is left as ADD with no matching errorFields.createChat. The optimistic chat therefore renders as perpetually pending (offline-styled) instead of failed, and no RBR error is shown. createGroupChat builds its own failureData and has the exact same gap: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L2017-L2035
The report-error surfaces already read this field, so once errorFields.createChat is set the RBR renders automatically — both the generic aggregator and the report-level error getter consume it: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/ReportUtils.ts#L9436-L9459 https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/ReportUtils.ts#L10266
What changes do you think we should make in order to solve the problem?
Set a create-failure error on the report in failureData whenever we optimistically create a new chat — mirroring the createChatThread error that already exists for threads, and the addWorkspaceRoom error used for rooms.
In openReport, inside the existing isCreatingNewReport block (the same block that sets pendingFields.createChat), add to failureData:
createGroupChat doesn't go through that path, so apply the same push to its failureData (keyed on the group reportID).
Because the success path already clears errorFields.createChat (and pendingFields.createChat), a successful creation won't latch the error — it only appears on a real failure, which keeps offline-first creation intact. getAllReportErrors aggregates every errorFields key and getReportRBRErrors reads errorFields.createChat directly, so no rendering change is needed — the RBR appears on the failed chat with the message "Unexpected error creating this chat. Please try again later."
What specific scenarios should we cover in the automated test to prevent this bug from happening again in the future?
openReport with a newReportObject (new 1:1 chat): after failureData is applied, the report has errorFields.createChat set, and getAllReportErrors returns that error for the report.
createGroupChat: on failure, the group report has errorFields.createChat set and surfaces via the RBR.
Success path: after successData is applied, errorFields.createChat and pendingFields.createChat are both cleared (no error latched on success).
Regression guard for threads: creating a new thread still surfaces a create error on failure.
What alternative solutions did you explore? (Optional)
Instead of adding a new push, broaden the existing isNewThread guard to isCreatingNewReport and reuse a single createChat key for both chats and threads (dropping the separate createChatThread push). It's less duplication, but createChatThread is consumed directly here: https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/pages/inbox/report/ReportActionItemParentAction.tsx#L135
so collapsing the keys would change the thread's error rendering at that call site. The additive approach keeps both consumers working, which is why I prefer it.
Set the create error centrally when an OPEN_REPORT request fails (e.g. keyed off the optimistic pendingFields.createChat) rather than duplicating the push in both openReport and createGroupChat. It's more DRY, but per-action failureData is the established pattern across the codebase and centralizing it is a larger, riskier refactor for a targeted bug — so I'd keep the fix local to the two creation actions.
Please re-state the problem that we are trying to solve in this issue.
On Web (Chrome/Safari), when "Simulate failing network requests" is enabled and the user starts a chat with someone they have never chatted with before, the app silently goes offline-mode and shows no error indicator. The expected behavior is that chat creation should visibly fail with an error on the newly created chat (matching the pattern used for isNewThread and other new-report creations).
What is the root cause of that problem?
In src/libs/actions/Report/index.ts, openReport builds failureData for a brand-new chat (isCreatingNewReport === true, entered via navigateToAndOpenReport → createAndOpenNewOptimisticChat at lines 2337-2346 passing newReportObject: fallbackChat), but inside the if (isCreatingNewReport) block (lines 1753-1877) it only pushes success/optimistic entries and a personal-details revert into failureData (line 1855). It never pushes an errorFields.createChat write onto the new report's Onyx key on failure — contrast the isNewThread branch at lines 1610-1616 which pushes {errorFields: {createChatThread: ...}}, and the success branch at lines 1836-1838 which is prepared to clear a createChat error that is never written. So when the server call fails, the new chat report has pendingFields.createChat: ADD set optimistically (line 1765) but no errorFields.createChat, leaving the UI with no red-brick-road error to display.
What changes do you think we should make in order to solve the problem?
In src/libs/actions/Report/index.ts inside the if (isCreatingNewReport) block (~line 1855), push a failureData entry mirroring the isNewThread shape: {onyxMethod: MERGE, key: REPORT_${reportID}, value: {errorFields: {createChat: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage')}, pendingFields: {createChat: null}}} so the optimistic pending state is cleared and an error is surfaced.
Also push a failureData entry for the created report action at REPORT_ACTIONS_${reportID} clearing pendingAction on optimisticCreatedAction.reportActionID and setting errors on it, so the created action is not left stuck in ADD state.
Verify the report-preview / LHN list item consumes errorFields.createChat (the same key the success path already clears at line 1837) so the error dot renders, matching the isNewThread UX.
No changes needed to NewChatPage or navigateToAndOpenReport — the fix is centralized in openReport and automatically covers all callers using newReportObject (lines 2343, 2461, 2587, 3568).
What alternative solutions did you explore? (Optional)
Two independent bugs combine to produce both reported symptoms "app turns to offline mode" and "no error displayed".
Bug 1 — Simulated failures trip the real offline detector. The "Simulate failing network requests" test tool makes HttpUtils throw FAILED_TO_FETCH for every request HttpUtils.ts:111-114
The FailureTracking middleware treats each of these as a genuine connectivity failure and calls recordFailure() with no guard for the test tool FailureTracking.ts:24-26
Once the app is offline, SequentialQueue.process() early-returns before it reaches the shouldFailAllRequests branch that applies failureDataSequentialQueue.ts:152-154
Log.info('[SequentialQueue] Applying failure and finally data because shouldFailAllRequests',false,{
command: requestToProcess.command,
updatesCount: onyxUpdates.length,
});
Onyx.update(onyxUpdates);
The OpenReport write is parked as ordinary offline work — never processed, and its error data never applied. The code itself acknowledges this conflation: turning the tool off must explicitly clear the accumulated sustained failures NetworkState.ts:180-191
optimistically marks the report with pendingFields.createChat: ADD ([Report/index.ts:1765-1768 https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1765-L1768 and fires the request. When the request fails, the queue applies failureData. For a new thread, failureData pushes errorFields.createChatThreadReport/index.ts:1612-1617 https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1612-L1617 rendered by ReportActionItemParentAction.tsx:135. But for a plain new DM isNewThread is false by default at [Report/index.ts:1500 https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1500 , failureData only rolls back optimistic personal details Report/index.ts:1857-1861 https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1857-L1861 — it never sets errorFields.createChat. The UI already reads this field: ReportActionItemCreated.tsx:67 reads report?.errorFields?.createChat for OfflineWithFeedback, and getCreationReportErrors at ReportUtils.ts:10266-10269 https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/ReportUtils.ts#L10266-L10269 aggregates it for the LHN. The field is simply never written on failure. createGroupChat builds its own failureData independently Report/index.ts:2030-2038 https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L2030-L2038 and has the exact same gap — it also never sets errorFields.createChat.
Both bugs must be fixed. Fixing only Bug 1 keeps the app online, sends the request, applies failureData, but that data has no error field to render. Fixing only Bug 2 adds the error field, but the app is already offline so failureData is never applied.
What changes do you think we should make in order to solve the problem?
1. Stop the simulate-failing tool from tripping the offline detector.
Expose the already-tracked failAllRequests flag from NetworkStateNetworkState.ts:16
so simulated failures do not feed the sustained-failure detector. Real FAILED_TO_FETCH and EXPENSIFY_SERVICE_INTERRUPTED failures still count. The guard reads the live in-memory flag (not Onyx) because the middleware runs synchronously in the request pipeline; failAllRequests is already kept current by the NETWORK subscriber NetworkState.ts:414-417
This is safe because shouldFailAllRequests is a debug tool real users never set — production connectivity detection is completely untouched. The guard is the clean counterpart of the existing setFailAllRequests(false) cleanup at NetworkState.ts:180-191
push a failure merge that sets errorFields.createChat with report.genericCreateReportFailureMessage. Scope it to !isNewThread so threads keep using errorFields.createChatThread through their separate rendering path at ReportActionItemParentAction.tsx:135
branches on this flag: if the report is still optimistic, dismissing the error deletes the phantom chat and navigates to Concierge (correct retry behavior). Flipping it would leave a zombie report the server never created.
The isNewThread / errorFields.createChatThread path is NOT touched. Thread errors render through ReportActionItemParentAction.tsx:135, a different consumer.
What alternative solutions did you explore? (Optional)
Only fix Bug 2 (add errorFields.createChat in openReport). Insufficient: the exact reported repro has the app already offline, so SequentialQueue exits at SequentialQueue.ts:152
before any failureData is applied. The error field is never rendered.
Only fix Bug 1 (FailureTracking guard). Insufficient: the app stays online and processes the request, but the applied failureData has no error field to render. The user still sees no error.
Centralize the error in the request layer (set errorFields.createChat whenever any OPEN_REPORT write with pendingFields.createChat fails). More DRY, but a larger refactor of per-action failureData — the established pattern across the codebase. Too risky for a targeted fix.
Clear pendingFields.createChat in failureData. Rejected: diverges from the workspace-chat precedent at Policy.ts:1766-1770
and is unnecessary — OfflineWithFeedback already handles the coexistence of pending and error states correctly.
Keep the modal open until OpenReport succeeds. Rejected: covers only one entry point (NewChatPage), duplicates request-failure handling outside the action that owns the optimistic state, and bypasses the established optimistic/OfflineWithFeedback pattern.
Please re-state the problem that we are trying to solve in this issue.
With the “Simulate failing network requests” test tool enabled, starting a chat with a brand‑new user (global create → Start chat → pick someone you’ve never chatted with) should fail the chat creation and surface an error on the new chat. Instead two things go wrong: the app silently slips into offline mode, and the optimistically‑created chat just sits in a grey pending state with no error (no red‑brick‑road) anywhere in the UI, so the tester has no way to tell that creation failed or to retry it.
Both halves need to be addressed for the exact reported repro to show an error, and the fix must stay correct for genuine offline, for new threads, for group chats, and for the error‑dismiss/retry path — the edge cases the existing proposals don’t fully cover.
What is the root cause of that problem?
There are two independent root causes, plus a set of state‑consistency edge cases that only surface once an error is actually written.
Part 1 — the reported “app turns to offline mode” symptom
The test tool makes every request through HttpUtils throw FAILED_TO_FETCH — the exact same signal a real outage produces, so nothing downstream can tell them apart:
// Test mode where all requests will succeed in the server, but fail to return a response
if(shouldFailAllRequests||shouldForceOffline){
thrownewHttpsError({
message: CONST.ERROR.FAILED_TO_FETCH,
});
}
The FailureTracking middleware treats each of those simulated FAILED_TO_FETCH outcomes as a genuine connectivity failure and feeds it to the FailureTracker — there is no guard for the simulate‑failing tool:
After enough sustained failures the tracker flips NetworkState, so getIsOffline() returns true — this is literally the “app turns to offline mode” the tester sees:
Once the app is considered offline, SequentialQueue.process() early‑returns before it ever reaches the branch that applies a request’s failureData, so the queued OpenReport write is parked as ordinary offline work and its failure handling never runs:
Log.info('[SequentialQueue] Unable to process. We are offline.');
returnPromise.resolve();
(The code already knows the tool conflates itself with a real outage — turning the tool off has to explicitly clear the accumulated sustained failures, confirming this is a known quirk of the simulator, not real offline: src/libs/NetworkState.ts#L180-L184.)
Part 2 — even when failure data IS applied, a new DM writes no error
Starting a chat with a new user goes through navigateToAndOpenReport, which calls openReport with a newReportObject — a persisted OPEN_REPORTWRITE:
For a brand‑new 1:1 chat isCreatingNewReport === true but isNewThread === false, so the only failure entry written for the report is the optimistic personal‑details rollback — there is no errorFields.createChat:
This matters because the queue does apply failureData in its shouldFailAllRequests branch (so an error would render if one were defined — meaning Part 2 is a real gap even after Part 1 is fixed, and even for a genuine online‑but‑failing response):
Log.info('[SequentialQueue] Applying failure and finally data because shouldFailAllRequests',false,{
command: requestToProcess.command,
updatesCount: onyxUpdates.length,
});
Onyx.update(onyxUpdates);
}
And the rendering path already exists — ReportActionItemCreated reads report.errorFields.createChat through OfflineWithFeedback; the field is simply never written on failure:
The aggregators that light up the LHN red dot and the report‑level RBR both consume errorFields.createChat, so no UI change is needed once the field is set:
// We are either adding a workspace room, creating a chat, or we're creating a report, it isn't possible for all of these to have errors for the same report at the same time, so
// simply looking up the first truthy value will get the relevant property if it's set.
(a) The optimistic CREATED action and isOptimisticReport are left stuck. In the same block, the optimistic CREATED report action is created with pendingAction: ADD and REPORT_METADATA.isOptimisticReport is set to true; both are only reset by successData. On failure neither is touched, so the created action stays grey/pending forever:
(b) The dismiss/retry path depends on isOptimisticReport — nobody accounts for this. When the user closes the RBR, clearCreateChatError branches on isOptimisticReport: if the error is set and the report is not optimistic it merely clears the error; otherwise it deletes the report and navigates to Concierge:
This is the subtle part: because a failed brand‑new DM was never created server‑side, we wantisOptimisticReport to remain true so that dismissing the error discards the phantom chat (retry = start the chat again). A naïve fix that also merges isOptimisticReport: false (or clears pendingFields.createChat) into failureData would leave a zombie report: dismissing would only clear the error and keep a chat the server never created. So the fix must add the error without flipping that metadata.
(c) createGroupChat has the identical gap. Group creation from the same Start‑chat surface builds its own failureData that likewise never sets errorFields.createChat, so a failed group chat is silent too:
What changes do you think we should make in order to solve the problem?
Fix both root causes and handle the Part‑3 edge cases. The original code for every location below is already shown via permalink in the root‑cause section, so only the actual changed/added TypeScript is shown here.
1. Stop the simulate‑failing tool from tripping the real offline detector
Expose the live flag from NetworkState (add the getter and export it):
Then guard recordFailure in FailureTracking so simulated failures don’t feed the sustained‑failure detector, while real FAILED_TO_FETCH / service‑interrupted failures still do:
.catch((error: Error)=>{constisConnectivityError=error.message===CONST.ERROR.FAILED_TO_FETCH||error.message===CONST.ERROR.EXPENSIFY_SERVICE_INTERRUPTED;// Don't let the "Simulate failing network requests" test tool trip the real sustained-failure// detector — otherwise the app flips to offline and SequentialQueue never applies failureData.if(isConnectivityError&&!NetworkState.getShouldFailAllRequests()){recordFailure();}throwerror;});
With this, the app stays online, SequentialQueue processes the OpenReport write, hits its shouldFailAllRequests branch, and applies failureData — which now (change 2) carries the create error.
2. Write the missing createChat error for a failed new DM
Inside the existing if (isCreatingNewReport) block, right after the personal‑details rollback push (src/libs/actions/Report/index.ts#L1855-L1859), add — scoped so it only fires for a genuinely optimistic new DM, leaving the existing isNewThread path untouched:
if(shouldAddPendingFields&&!isNewThread){failureData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,value: {errorFields: {createChat: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage')}},});// Un-stick the optimistic CREATED action so it doesn't render as perpetually pending.failureData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,value: {[optimisticCreatedAction.reportActionID]: {pendingAction: null}},});}
Deliberately not included (Part‑3 edge cases): we do not clear pendingFields.createChat (so the RBR renders over the pending row, matching the workspace‑chat precedent) and we do not merge isOptimisticReport: false, so clearCreateChatError treats a dismissed failure as “discard the never‑created chat” rather than stranding a zombie report. The helper and translation key already exist (used one branch above for createChatThread), so no new strings are needed.
3. Apply the same error to createGroupChat
In createGroupChat’s failureData (src/libs/actions/Report/index.ts#L2018-L2038), add:
Because centralizing on openReport covers every caller that passes a newReportObject (e.g. navigateToAndOpenReport and navigateToAndOpenReportWithAccountIDs), and createGroupChat is the one create‑path that builds its own failureData, these two edits cover all Start‑chat entry points without any UI‑layer or backend change. The success path already clears errorFields.createChat, so a successful create never latches an error, and when the user is genuinely offline SequentialQueue returns early and never applies failureData — so the error only appears on a true failure, not on legitimately queued offline work.
What specific scenarios should we cover in the automated test to prevent this bug from happening again in the future?
FailureTracking:FAILED_TO_FETCH increments the sustained‑failure counter for real connectivity errors, but is not recorded while shouldFailAllRequests is enabled.
New 1:1 chat (openReport with newReportObject): after failureData is applied, the report has errorFields.createChat set, the optimistic CREATED action’s pendingAction is cleared, and getCreationReportErrors/getAllReportErrors return that error.
Dismiss/retry: with isOptimisticReport still true, closing the RBR routes through the delete‑and‑go‑to‑Concierge branch of clearCreateChatError (the failed chat is discarded, not kept).
Group chat (createGroupChat): on failure the group report gets errorFields.createChat and surfaces the RBR.
Success path: after successData is applied, both errorFields.createChat and pendingFields.createChat are cleared (no latched error).
Regression guard for threads: creating a new thread still writes errorFields.createChatThread and does not get the DM createChat error.
What alternative solutions did you explore? (Optional)
Only add errorFields.createChat in openReport (what most existing proposals do). Necessary but not sufficient: for the reported simulate‑failing repro the app is already in offline mode, so SequentialQueue exits before any failureData is applied and the error never shows. That’s why the Part‑1 FailureTracking guard is required in addition.
Broaden the existing isNewThread guard to isCreatingNewReport and reuse a single createChat key for both chats and threads. Less duplication, but createChatThread is consumed directly at a different call site (src/pages/inbox/report/ReportActionItemParentAction.tsx), so collapsing the keys would change thread error rendering. The additive, scoped approach keeps both consumers intact.
Also merge isOptimisticReport: false / clear pendingFields.createChat on failure. Rejected — this breaks the dismiss/retry semantics described in Part 3(b): it would keep a report the server never created and prevent a clean “start over.”
Handle it in NewChatPage.selectOption() (or keep the modal open until OpenReport succeeds). Rejected — it covers only one entry point, duplicates request‑failure handling outside the action that owns the optimistic create‑chat state, and diverges from the established optimistic/OfflineWithFeedback pattern.
Close as WAI. If product decides that converting simulated failures into offline mode and silently queuing the chat is the intended offline‑first behavior, this is a no‑op. I don’t recommend it: the tester’s expectation (“chat creation should fail and an error should be shown”) is exactly what the existing thread/workspace‑chat paths already do, so the DM path is inconsistent rather than intentional.
changed the title [-]No error is displayed when creating a chat with failing network request[/-][+][$250] No error is displayed when creating a chat with failing network request[/+]on Jul 10, 2026
@MelvinBot two PRs were needed here. which do you think it most accurate for payment amount
$250 cuz the amount of work was expected
$375 cuz one was a followup (or the amount of work warrants an increase)
$500 cuz PRs are separate and should be $250 each.
Both PRs are by the same contributor (nabi-ebrahimi, reviewed by dmkt9), and the second was a genuine followup on the same flow rather than a separate bug:
Not $250 (all expected): it wasn't a regression the contributor introduced in their own PR that they'd fix for free. It needed a distinct root cause, its own review round, and a real code change (+30/-5) to fully deliver the reported behavior (error shown and participant still identifiable).
So it's more than the base scope but less than two full jobs — $375 is the fair middle. That matches what nabi-ebrahimi requested above too.
Activity
MelvinBot commentedon Jul 10, 2026
Proposal
What is the root cause of that problem?
Two things combine here — one is arguably by-design, the other is a real gap:
1. "Simulate failing network requests" gets converted into offline mode. The dev tool only sets a
shouldFailAllRequestsflag (Network.ts:16), which makes every HTTP call throwFAILED_TO_FETCH(HttpUtils.ts:111) — indistinguishable from a real outage. TheFailureTrackercounts these and, after 3 failures in 10s, fires a sustained-failure hard stop (FailureTracker.ts:54) that flipsgetIsOffline()totrue(NetworkState.ts:36). That is why the app "turns to offline mode."2. New-chat creation is an optimistic write with no error path. Starting a chat with a new user calls
openReportwith anewReportObject— aWRITEcommand that is queued optimistically (Report/index.ts:2326). Once the app is offline,SequentialQueuestops processing and the request just waits (SequentialQueue.ts:152) — the chat shows a normal pending/greyed state (pendingFields.createChat = ADD), which looks exactly like normal offline optimistic behavior. Critically, thefailureDatafor a brand-new DM never setserrorFields.createChat(unlike new threads, which do seterrorFields.createChatThread). So even if the request had failed while still online, no red-brick error would ever appear for a new DM.Full data flow & evidence
navigateToAndOpenReport→getChatByParticipantsempty →createAndOpenNewOptimisticChat→openReport({newReportObject})+ immediate navigate into the chat.openReportbuilds optimistic data withpendingFields.createChat = ADD(Report/index.ts:1753) and callsAPI.paginate(WRITE, OPEN_REPORT, ...).HttpUtilsthrowsFAILED_TO_FETCH→FailureTrackingmiddleware records it (FailureTracking.ts:21).SequentialQueuereturns early → queuedOpenReportnever re-runs.failureDatahas nocreateChaterror field → no error UI. Chat stays "pending."Thresholds:
COUNT: 3,WINDOW_MS: 10000inCONST/index.ts.What changes do you think we should make in order to solve the problem?
First, a product decision is needed: is this actually a bug, or working-as-intended? Because the
FailureTrackerdeliberately treats failing requests as an outage, the app entering offline mode — and then queuing the new chat silently, the same as any other offline optimistic write — is the current intended offline-first behavior. Under that lens, "no error shown" is expected: the chat is queued and will be created when connectivity returns.If product decides a new-chat creation failure should surface an error to the user, the fix is to add a
createChaterror path for new DMs, mirroring the existing new-thread handling: pusherrorFields.createChatinto thefailureDatain the new-report branch ofopenReport(aroundReport/index.ts:1855), and render it via the report's existing red-brick-road UI. Note this alone won't change the simulate-failing repro, because the sustained-failure detection makes the app offline before the error can apply — so this only helps genuine online-but-failing responses.What alternative solutions did you explore? (Optional)
Close as WAI if the offline-conversion behavior is intended and offline chat-queueing is the desired UX.
Confidence: Medium — the code mechanism is confirmed with file:line evidence (high), but whether the observed behavior is a bug vs. intended offline-first behavior is a product/design call the mechanism can't settle.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/95864)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
MobileMage commentedon Jul 10, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-07-11 00:57:23 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
With the "Simulate failing network requests" test tool enabled, starting a chat with a brand-new user (global create > Start chat) creates the chat optimistically but never surfaces any error when the server call fails. The app just drifts into offline mode and the new chat sits in a silent pending state, so the tester has no indication that creation failed.
What is the root cause of that problem?
The "Start chat" flow runs
navigateToAndOpenReportinNewChatPage/index.tsx(line 396), which for a new participant callscreateAndOpenNewOptimisticChatand dispatchesopenReportwith anewReportObject.openReportbuilds the optimistic report withpendingFields.createChat = ADDand firesOPEN_REPORTas a persisted WRITE viaAPI.paginate. The test tool works by making every request throughHttpUtilsthrowFAILED_TO_FETCH(HttpUtils.tsline ~110), which is the exact same signal as a genuine offline request. When theOPEN_REPORTrequest is processed and throws, theSequentialQueuetakes itsshouldFailAllRequestsbranch and applies the request'sfailureDatabefore dropping it:App/src/libs/Network/SequentialQueue.ts
Lines 228 to 230 in 7e6a5f5
So
failureDatais applied. The real gap is what thatfailureDatacontains. For a brand-new DM,openReport'sisCreatingNewReportbranch only clears the loading flag and rolls back the optimistic personal details — it never writes any error onto the report:App/src/libs/actions/Report/index.ts
Lines 1855 to 1859 in 7e6a5f5
Because no
errorFields.createChatis set, the optimistic report is left withpendingFields.createChatstillADDand zero errors.getCreationReportErrors/getAllReportErrorsinReportUtils.tstherefore find nothing, so the LHN shows no red brick road and theReportHeaderOfflineWithFeedback(which readsgetReportOfflinePendingActionAndErrors) renders only a grey pending state. That is the "no error" symptom. The separate "turns offline" symptom comes from the same signal: repeatedFAILED_TO_FETCHoutcomes accumulate inFailureTrackerand flipsustainedFailuresActiveonce at least 3 failures have occurred and 10 seconds have elapsed since the first one (CONST.NETWORK.SUSTAINED_FAILURE_*). That flip is mostly cosmetic, but it has one consequence that matters for this bug: once it happens,SequentialQueuestops processing (pushparks new writes atSequentialQueue.tslines 596-603 andprocessreturns early at 152-155), so in a slow run theOPEN_REPORTwrite can be parked before itsfailureDatais ever applied, and even a correct error field would not render until reconnect. A complete fix has to cover both timings, which the second change below does.Notably the workspace-member-chat creation path already does this correctly — its failure handler sets
errorFields.createChat, which is why that flow shows an error and the DM flow does not:App/src/libs/actions/Policy/Policy.ts
Lines 1766 to 1770 in 7e6a5f5
I reproduced this by starting a chat with a brand-new participant while all outgoing requests are set to fail, and the new DM lands in the LHN in a grey pending state with no red brick road and no error banner anywhere in the UI. Checking the underlying report data afterward, the optimistic report still carries pendingFields.createChat set to 'add' with no error fields attached at all, so the state was written correctly and nothing threw or logged an error, yet the UI gives the user no way to notice or retry the failed chat. That traces exactly to openReport's isCreatingNewReport failure handling in src/libs/actions/Report/index.ts, which on failure clears isLoadingInitialReportActions and rolls back the optimistic personal details but never sets errorFields.createChat for a plain DM, unlike the workspace-chat failure path in src/libs/actions/Policy/Policy.ts, which does push errorFields.createChat. Because nothing ever writes that error field, the report has no mechanism to signal failure and the chat just sits there looking like it's still loading.
What changes do you think we should make in order to solve the problem?
Add the missing error to
openReport'sfailureDatainside theisCreatingNewReportblock (right next to the existing personal-details rollback atReport/index.tsline 1855), mirroring the established workspace-chat pattern:The helper and translation key already exist and are used one branch above for the
createChatThreadcase, so no new strings are needed. This makes a failed create surface a red brick road on the chat viagetAllReportErrors(LHN indicator) and viagetCreationReportErrorsinReportHeader, which is exactly "an error should be shown." The change is scoped by theisCreatingNewReportguard so it only fires when we actually force a new report — the re-open/existing-chat path innavigateToAndOpenReport(which callsopenReportwithoutnewReportObject) is unaffected. It is also safe for genuine offline: the queue returns early and never appliesfailureDatawhile offline (SequentialQueue.tsline 152), so the error only appears when the request truly reaches the server and fails, not while a chat is legitimately queued for later sync.Second, to make the reported repro deterministic regardless of timing, guard the
FailureTrackingmiddleware so simulated failures don't feed the sustained-failure detector: skiprecordFailure()whileshouldFailAllRequestsis enabled, via anOnyx.connectWithoutViewonONYXKEYS.NETWORKinsideFailureTracking.ts, mirroring whatSequentialQueue.tslines 33-43 already do for the same flag. Without this, a run where 3+ requests fail and more than 10 seconds pass before the chat is confirmed flips the app offline first and parks theOPEN_REPORTwrite, so no error can render (the parked request does self-heal on tool-off viaNetworkState.setFailAllRequests, but the tester sees nothing in the meantime). With the guard, the app stays online under simulation, the write always reaches theshouldFailAllRequestsbranch (SequentialQueue.tslines 228-236) that appliesfailureDataon the first failure with no retry loop, and the newerrorFields.createChatrenders every time. Offline simulation remains available through the separate "Force offline" tool, and the existing recovery inNetworkState.setFailAllRequestsbecomes a harmless backstop. The guard alone would not fix the issue, since appliedfailureDatawrites no error field today; theerrorFields.createChataddition above stays the load-bearing change.What alternative solutions did you explore? (Optional)
I considered also clearing
pendingFields.createChatinfailureData, but the workspace-chat precedent deliberately leaves it set so the RBR renders over the pending row, andOfflineWithFeedbackalready prioritizes the error state, so clearing it is unnecessary and would diverge from the existing pattern.David-2002065 commentedon Jul 10, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When "Simulate failing network requests" is enabled and you start a chat with a user you've never chatted with before, the chat creation request fails but no error is surfaced — the optimistic chat stays in place and the app just slips into offline mode.
What is the root cause of that problem?
With "Simulate failing network requests" on, the SequentialQueue does handle the failure correctly for persisted writes: it applies the request's
failureDataand drops the request instead of retrying, so an error would be shown if one were defined:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/Network/SequentialQueue.ts#L228-L235Starting a chat with a new user goes through
navigateToAndOpenReport→openReportwith anewReportObject, which is a persistedOPEN_REPORTwrite.openReportoptimistically marks the new report withpendingFields.createChat = ADD:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L1753-L1766But its
failureDataonly attaches a create-failure error when the report is a new thread — it never sets one for a plain new chat:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L1610-L1616A brand-new 1:1 chat has
isCreatingNewReport === truebutisNewThread === false:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L1518So when
OPEN_REPORTfails, the queue appliesfailureDatathat contains no error for the report —pendingFields.createChatis left asADDwith no matchingerrorFields.createChat. The optimistic chat therefore renders as perpetually pending (offline-styled) instead of failed, and no RBR error is shown.createGroupChatbuilds its ownfailureDataand has the exact same gap:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/actions/Report/index.ts#L2017-L2035The report-error surfaces already read this field, so once
errorFields.createChatis set the RBR renders automatically — both the generic aggregator and the report-level error getter consume it:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/ReportUtils.ts#L9436-L9459https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/libs/ReportUtils.ts#L10266What changes do you think we should make in order to solve the problem?
Set a create-failure error on the report in
failureDatawhenever we optimistically create a new chat — mirroring thecreateChatThreaderror that already exists for threads, and theaddWorkspaceRoomerror used for rooms.In
openReport, inside the existingisCreatingNewReportblock (the same block that setspendingFields.createChat), add tofailureData:createGroupChatdoesn't go through that path, so apply the same push to itsfailureData(keyed on the groupreportID).Because the success path already clears
errorFields.createChat(andpendingFields.createChat), a successful creation won't latch the error — it only appears on a real failure, which keeps offline-first creation intact.getAllReportErrorsaggregates everyerrorFieldskey andgetReportRBRErrorsreadserrorFields.createChatdirectly, so no rendering change is needed — the RBR appears on the failed chat with the message "Unexpected error creating this chat. Please try again later."What specific scenarios should we cover in the automated test to prevent this bug from happening again in the future?
openReportwith anewReportObject(new 1:1 chat): afterfailureDatais applied, the report haserrorFields.createChatset, andgetAllReportErrorsreturns that error for the report.createGroupChat: on failure, the group report haserrorFields.createChatset and surfaces via the RBR.successDatais applied,errorFields.createChatandpendingFields.createChatare both cleared (no error latched on success).What alternative solutions did you explore? (Optional)
isNewThreadguard toisCreatingNewReportand reuse a singlecreateChatkey for both chats and threads (dropping the separatecreateChatThreadpush). It's less duplication, butcreateChatThreadis consumed directly here:https://github.com/Expensify/App/blob/7e6a5f5a97136ee8e8c546b75df8a9be5a3dba07/src/pages/inbox/report/ReportActionItemParentAction.tsx#L135so collapsing the keys would change the thread's error rendering at that call site. The additive approach keeps both consumers working, which is why I prefer it.
OPEN_REPORTrequest fails (e.g. keyed off the optimisticpendingFields.createChat) rather than duplicating the push in bothopenReportandcreateGroupChat. It's more DRY, but per-actionfailureDatais the established pattern across the codebase and centralizing it is a larger, riskier refactor for a targeted bug — so I'd keep the fix local to the two creation actions.aswin-s commentedon Jul 10, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web (Chrome/Safari), when "Simulate failing network requests" is enabled and the user starts a chat with someone they have never chatted with before, the app silently goes offline-mode and shows no error indicator. The expected behavior is that chat creation should visibly fail with an error on the newly created chat (matching the pattern used for
isNewThreadand other new-report creations).What is the root cause of that problem?
In
src/libs/actions/Report/index.ts,openReportbuildsfailureDatafor a brand-new chat (isCreatingNewReport === true, entered vianavigateToAndOpenReport→createAndOpenNewOptimisticChatat lines 2337-2346 passingnewReportObject: fallbackChat), but inside theif (isCreatingNewReport)block (lines 1753-1877) it only pushes success/optimistic entries and a personal-details revert intofailureData(line 1855). It never pushes anerrorFields.createChatwrite onto the new report's Onyx key on failure — contrast theisNewThreadbranch at lines 1610-1616 which pushes{errorFields: {createChatThread: ...}}, and the success branch at lines 1836-1838 which is prepared to clear acreateChaterror that is never written. So when the server call fails, the new chat report haspendingFields.createChat: ADDset optimistically (line 1765) but noerrorFields.createChat, leaving the UI with no red-brick-road error to display.What changes do you think we should make in order to solve the problem?
src/libs/actions/Report/index.tsinside theif (isCreatingNewReport)block (~line 1855), push afailureDataentry mirroring theisNewThreadshape:{onyxMethod: MERGE, key: REPORT_${reportID}, value: {errorFields: {createChat: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage')}, pendingFields: {createChat: null}}}so the optimistic pending state is cleared and an error is surfaced.failureDataentry for the created report action atREPORT_ACTIONS_${reportID}clearingpendingActiononoptimisticCreatedAction.reportActionIDand settingerrorson it, so the created action is not left stuck inADDstate.errorFields.createChat(the same key the success path already clears at line 1837) so the error dot renders, matching theisNewThreadUX.NewChatPageornavigateToAndOpenReport— the fix is centralized inopenReportand automatically covers all callers usingnewReportObject(lines 2343, 2461, 2587, 3568).What alternative solutions did you explore? (Optional)
nabi-ebrahimi commentedon Jul 10, 2026
Proposal
What is the root cause of that problem?
Two independent bugs combine to produce both reported symptoms "app turns to offline mode" and "no error displayed".
Bug 1 — Simulated failures trip the real offline detector. The "Simulate failing network requests" test tool makes
HttpUtilsthrowFAILED_TO_FETCHfor every requestHttpUtils.ts:111-114App/src/libs/HttpUtils.ts
Lines 111 to 114 in e6cc804
FailureTrackingmiddleware treats each of these as a genuine connectivity failure and callsrecordFailure()with no guard for the test toolFailureTracking.ts:24-26App/src/libs/Middleware/FailureTracking.ts
Lines 24 to 26 in e6cc804
FailureTracker.ts:48-58App/src/libs/FailureTracker.ts
Lines 48 to 58 in e6cc804
sustainedFailuresActive = trueinNetworkStateNetworkState.ts:34App/src/libs/NetworkState.ts
Line 34 in e6cc804
getIsOffline()returntrueNetworkState.ts:36-37App/src/libs/NetworkState.ts
Lines 36 to 37 in e6cc804
SequentialQueue.process()early-returns before it reaches theshouldFailAllRequestsbranch that appliesfailureDataSequentialQueue.ts:152-154App/src/libs/Network/SequentialQueue.ts
Lines 152 to 154 in e6cc804
SequentialQueue.ts:228-235App/src/libs/Network/SequentialQueue.ts
Lines 228 to 235 in e6cc804
OpenReportwrite is parked as ordinary offline work — never processed, and its error data never applied. The code itself acknowledges this conflation: turning the tool off must explicitly clear the accumulated sustained failuresNetworkState.ts:180-191App/src/libs/NetworkState.ts
Lines 180 to 191 in e6cc804
Bug 2 — New-chat creation has no error in its failure data. Starting a chat with a new user calls
navigateToAndOpenReportReport/index.ts:2339-2345App/src/libs/actions/Report/index.ts
Lines 2339 to 2345 in e6cc804
openReportwith anewReportObject. This setsisCreatingNewReport = trueReport/index.ts:1520App/src/libs/actions/Report/index.ts
Line 1520 in e6cc804
pendingFields.createChat: ADD([Report/index.ts:1765-1768https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1765-L1768 and fires the request. When the request fails, the queue appliesfailureData. For a new thread,failureDatapusheserrorFields.createChatThreadReport/index.ts:1612-1617https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1612-L1617 rendered byReportActionItemParentAction.tsx:135. But for a plain new DMisNewThreadisfalseby default at [Report/index.ts:1500https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1500 ,failureDataonly rolls back optimistic personal detailsReport/index.ts:1857-1861https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L1857-L1861 — it never setserrorFields.createChat. The UI already reads this field:ReportActionItemCreated.tsx:67readsreport?.errorFields?.createChatforOfflineWithFeedback, andgetCreationReportErrorsatReportUtils.ts:10266-10269https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/ReportUtils.ts#L10266-L10269 aggregates it for the LHN. The field is simply never written on failure.createGroupChatbuilds its ownfailureDataindependentlyReport/index.ts:2030-2038https://github.com/Expensify/App/blob/e6cc80496e503e1ed487e89629e9ea7997c70686/src/libs/actions/Report/index.ts#L2030-L2038 and has the exact same gap — it also never setserrorFields.createChat.Both bugs must be fixed. Fixing only Bug 1 keeps the app online, sends the request, applies
failureData, but that data has no error field to render. Fixing only Bug 2 adds the error field, but the app is already offline sofailureDatais never applied.What changes do you think we should make in order to solve the problem?
1. Stop the simulate-failing tool from tripping the offline detector.
Expose the already-tracked
failAllRequestsflag fromNetworkStateNetworkState.ts:16App/src/libs/NetworkState.ts
Line 16 in e6cc804
recordFailure()inFailureTrackingFailureTracking.ts:24-26App/src/libs/Middleware/FailureTracking.ts
Lines 24 to 26 in e6cc804
FAILED_TO_FETCHandEXPENSIFY_SERVICE_INTERRUPTEDfailures still count. The guard reads the live in-memory flag (not Onyx) because the middleware runs synchronously in the request pipeline;failAllRequestsis already kept current by theNETWORKsubscriberNetworkState.ts:414-417App/src/libs/NetworkState.ts
Lines 414 to 417 in e6cc804
shouldFailAllRequestsis a debug tool real users never set — production connectivity detection is completely untouched. The guard is the clean counterpart of the existingsetFailAllRequests(false)cleanup atNetworkState.ts:180-191App/src/libs/NetworkState.ts
Lines 180 to 191 in e6cc804
2. Write the missing
createChaterror for a failed new DM.In
openReport, inside theisCreatingNewReportblock after the personal-details rollback atReport/index.ts:1857-1861App/src/libs/actions/Report/index.ts
Lines 1857 to 1861 in e6cc804
errorFields.createChatwithreport.genericCreateReportFailureMessage. Scope it to!isNewThreadso threads keep usingerrorFields.createChatThreadthrough their separate rendering path atReportActionItemParentAction.tsx:135App/src/pages/inbox/report/ReportActionItemParentAction.tsx
Line 135 in e6cc804
CREATEDreport action'spendingActiontonull— the success path does the sameReport/index.ts:1797App/src/libs/actions/Report/index.ts
Line 1797 in e6cc804
ADDstate on failure. The helper and translation key already exist — no new strings needed.3. Apply the same error to
createGroupChat.createGroupChatbuilds its ownfailureDataarray independently fromopenReportReport/index.ts:2030-2038App/src/libs/actions/Report/index.ts
Lines 2030 to 2038 in e6cc804
errorFields.createChatpush andCREATEDactionpendingActioncleanup to itsfailureDataarray.What is deliberately NOT changed:
pendingFields.createChatis NOT cleared infailureData. The workspace-chat precedent atPolicy.ts:1766-1770App/src/libs/actions/Policy/Policy.ts
Lines 1766 to 1770 in e6cc804
OfflineWithFeedbackatReportActionItemCreated.tsx:66-67App/src/pages/inbox/report/ReportActionItemCreated.tsx
Lines 66 to 67 in e6cc804
isOptimisticReportis NOT flipped tofalseinfailureData. The dismiss/retry handlerclearCreateChatErroratReport/index.ts:4480-4484App/src/libs/actions/Report/index.ts
Lines 4480 to 4484 in e6cc804
isNewThread/errorFields.createChatThreadpath is NOT touched. Thread errors render throughReportActionItemParentAction.tsx:135, a different consumer.What alternative solutions did you explore? (Optional)
errorFields.createChatinopenReport). Insufficient: the exact reported repro has the app already offline, soSequentialQueueexits atSequentialQueue.ts:152App/src/libs/Network/SequentialQueue.ts
Line 152 in e6cc804
failureDatais applied. The error field is never rendered.failureDatahas no error field to render. The user still sees no error.errorFields.createChatwhenever anyOPEN_REPORTwrite withpendingFields.createChatfails). More DRY, but a larger refactor of per-actionfailureData— the established pattern across the codebase. Too risky for a targeted fix.pendingFields.createChatinfailureData. Rejected: diverges from the workspace-chat precedent atPolicy.ts:1766-1770App/src/libs/actions/Policy/Policy.ts
Lines 1766 to 1770 in e6cc804
OfflineWithFeedbackalready handles the coexistence of pending and error states correctly.OpenReportsucceeds. Rejected: covers only one entry point (NewChatPage), duplicates request-failure handling outside the action that owns the optimistic state, and bypasses the established optimistic/OfflineWithFeedbackpattern.Fixed Demo:
abbasifaizan70 commentedon Jul 10, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
With the “Simulate failing network requests” test tool enabled, starting a chat with a brand‑new user (global create → Start chat → pick someone you’ve never chatted with) should fail the chat creation and surface an error on the new chat. Instead two things go wrong: the app silently slips into offline mode, and the optimistically‑created chat just sits in a grey pending state with no error (no red‑brick‑road) anywhere in the UI, so the tester has no way to tell that creation failed or to retry it.
Both halves need to be addressed for the exact reported repro to show an error, and the fix must stay correct for genuine offline, for new threads, for group chats, and for the error‑dismiss/retry path — the edge cases the existing proposals don’t fully cover.
What is the root cause of that problem?
There are two independent root causes, plus a set of state‑consistency edge cases that only surface once an error is actually written.
Part 1 — the reported “app turns to offline mode” symptom
The test tool makes every request through
HttpUtilsthrowFAILED_TO_FETCH— the exact same signal a real outage produces, so nothing downstream can tell them apart:App/src/libs/HttpUtils.ts
Lines 109 to 115 in 7e6a5f5
The
FailureTrackingmiddleware treats each of those simulatedFAILED_TO_FETCHoutcomes as a genuine connectivity failure and feeds it to theFailureTracker— there is no guard for the simulate‑failing tool:App/src/libs/Middleware/FailureTracking.ts
Lines 21 to 29 in 7e6a5f5
After enough sustained failures the tracker flips
NetworkState, sogetIsOffline()returnstrue— this is literally the “app turns to offline mode” the tester sees:App/src/libs/NetworkState.ts
Lines 34 to 38 in 7e6a5f5
Once the app is considered offline,
SequentialQueue.process()early‑returns before it ever reaches the branch that applies a request’sfailureData, so the queuedOpenReportwrite is parked as ordinary offline work and its failure handling never runs:App/src/libs/Network/SequentialQueue.ts
Lines 152 to 154 in 7e6a5f5
(The code already knows the tool conflates itself with a real outage — turning the tool off has to explicitly clear the accumulated sustained failures, confirming this is a known quirk of the simulator, not real offline:
src/libs/NetworkState.ts#L180-L184.)Part 2 — even when failure data IS applied, a new DM writes no error
Starting a chat with a new user goes through
navigateToAndOpenReport, which callsopenReportwith anewReportObject— a persistedOPEN_REPORTWRITE:App/src/libs/actions/Report/index.ts
Lines 2337 to 2346 in 7e6a5f5
openReportoptimistically marks the new report withpendingFields.createChat = ADD:App/src/libs/actions/Report/index.ts
Lines 1762 to 1766 in 7e6a5f5
But its
failureDataonly pushes a create error when the report is a new thread — never for a plain new DM:App/src/libs/actions/Report/index.ts
Lines 1613 to 1616 in 7e6a5f5
For a brand‑new 1:1 chat
isCreatingNewReport === truebutisNewThread === false, so the only failure entry written for the report is the optimistic personal‑details rollback — there is noerrorFields.createChat:App/src/libs/actions/Report/index.ts
Lines 1855 to 1859 in 7e6a5f5
This matters because the queue does apply
failureDatain itsshouldFailAllRequestsbranch (so an error would render if one were defined — meaning Part 2 is a real gap even after Part 1 is fixed, and even for a genuine online‑but‑failing response):App/src/libs/Network/SequentialQueue.ts
Lines 227 to 236 in 7e6a5f5
And the rendering path already exists —
ReportActionItemCreatedreadsreport.errorFields.createChatthroughOfflineWithFeedback; the field is simply never written on failure:App/src/pages/inbox/report/ReportActionItemCreated.tsx
Lines 64 to 80 in 7e6a5f5
The aggregators that light up the LHN red dot and the report‑level RBR both consume
errorFields.createChat, so no UI change is needed once the field is set:App/src/libs/ReportUtils.ts
Lines 10261 to 10266 in 7e6a5f5
Part 3 — edge cases the other proposals miss
(a) The optimistic
CREATEDaction andisOptimisticReportare left stuck. In the same block, the optimisticCREATEDreport action is created withpendingAction: ADDandREPORT_METADATA.isOptimisticReportis set totrue; both are only reset bysuccessData. On failure neither is touched, so the created action stays grey/pending forever:App/src/libs/actions/Report/index.ts
Lines 1777 to 1789 in 7e6a5f5
(b) The dismiss/retry path depends on
isOptimisticReport— nobody accounts for this. When the user closes the RBR,clearCreateChatErrorbranches onisOptimisticReport: if the error is set and the report is not optimistic it merely clears the error; otherwise it deletes the report and navigates to Concierge:App/src/libs/actions/Report/index.ts
Lines 4478 to 4483 in 7e6a5f5
This is the subtle part: because a failed brand‑new DM was never created server‑side, we want
isOptimisticReportto remaintrueso that dismissing the error discards the phantom chat (retry = start the chat again). A naïve fix that also mergesisOptimisticReport: false(or clearspendingFields.createChat) intofailureDatawould leave a zombie report: dismissing would only clear the error and keep a chat the server never created. So the fix must add the error without flipping that metadata.(c)
createGroupChathas the identical gap. Group creation from the same Start‑chat surface builds its ownfailureDatathat likewise never setserrorFields.createChat, so a failed group chat is silent too:App/src/libs/actions/Report/index.ts
Lines 2018 to 2038 in 7e6a5f5
What changes do you think we should make in order to solve the problem?
Fix both root causes and handle the Part‑3 edge cases. The original code for every location below is already shown via permalink in the root‑cause section, so only the actual changed/added TypeScript is shown here.
1. Stop the simulate‑failing tool from tripping the real offline detector
Expose the live flag from
NetworkState(add the getter and export it):Then guard
recordFailureinFailureTrackingso simulated failures don’t feed the sustained‑failure detector, while realFAILED_TO_FETCH/ service‑interrupted failures still do:With this, the app stays online,
SequentialQueueprocesses theOpenReportwrite, hits itsshouldFailAllRequestsbranch, and appliesfailureData— which now (change 2) carries the create error.2. Write the missing
createChaterror for a failed new DMInside the existing
if (isCreatingNewReport)block, right after the personal‑details rollback push (src/libs/actions/Report/index.ts#L1855-L1859), add — scoped so it only fires for a genuinely optimistic new DM, leaving the existingisNewThreadpath untouched:Deliberately not included (Part‑3 edge cases): we do not clear
pendingFields.createChat(so the RBR renders over the pending row, matching the workspace‑chat precedent) and we do not mergeisOptimisticReport: false, soclearCreateChatErrortreats a dismissed failure as “discard the never‑created chat” rather than stranding a zombie report. The helper and translation key already exist (used one branch above forcreateChatThread), so no new strings are needed.3. Apply the same error to
createGroupChatIn
createGroupChat’sfailureData(src/libs/actions/Report/index.ts#L2018-L2038), add:Because centralizing on
openReportcovers every caller that passes anewReportObject(e.g.navigateToAndOpenReportandnavigateToAndOpenReportWithAccountIDs), andcreateGroupChatis the one create‑path that builds its ownfailureData, these two edits cover all Start‑chat entry points without any UI‑layer or backend change. The success path already clearserrorFields.createChat, so a successful create never latches an error, and when the user is genuinely offlineSequentialQueuereturns early and never appliesfailureData— so the error only appears on a true failure, not on legitimately queued offline work.What specific scenarios should we cover in the automated test to prevent this bug from happening again in the future?
FAILED_TO_FETCHincrements the sustained‑failure counter for real connectivity errors, but is not recorded whileshouldFailAllRequestsis enabled.openReportwithnewReportObject): afterfailureDatais applied, the report haserrorFields.createChatset, the optimisticCREATEDaction’spendingActionis cleared, andgetCreationReportErrors/getAllReportErrorsreturn that error.isOptimisticReportstilltrue, closing the RBR routes through the delete‑and‑go‑to‑Concierge branch ofclearCreateChatError(the failed chat is discarded, not kept).createGroupChat): on failure the group report getserrorFields.createChatand surfaces the RBR.successDatais applied, botherrorFields.createChatandpendingFields.createChatare cleared (no latched error).errorFields.createChatThreadand does not get the DMcreateChaterror.What alternative solutions did you explore? (Optional)
errorFields.createChatinopenReport(what most existing proposals do). Necessary but not sufficient: for the reported simulate‑failing repro the app is already in offline mode, soSequentialQueueexits before anyfailureDatais applied and the error never shows. That’s why the Part‑1FailureTrackingguard is required in addition.isNewThreadguard toisCreatingNewReportand reuse a singlecreateChatkey for both chats and threads. Less duplication, butcreateChatThreadis consumed directly at a different call site (src/pages/inbox/report/ReportActionItemParentAction.tsx), so collapsing the keys would change thread error rendering. The additive, scoped approach keeps both consumers intact.isOptimisticReport: false/ clearpendingFields.createChaton failure. Rejected — this breaks the dismiss/retry semantics described in Part 3(b): it would keep a report the server never created and prevent a clean “start over.”NewChatPage.selectOption()(or keep the modal open untilOpenReportsucceeds). Rejected — it covers only one entry point, duplicates request‑failure handling outside the action that owns the optimistic create‑chat state, and diverges from the established optimistic/OfflineWithFeedbackpattern.lorretheboy commentedon Jul 10, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
melvin-bot commentedon Jul 10, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dmkt9 (
External)[-]No error is displayed when creating a chat with failing network request[/-][+][$250] No error is displayed when creating a chat with failing network request[/+]melvin-bot commentedon Jul 10, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022075648566432231802
68 remaining items
melvin-bot commentedon Aug 11, 2026
Payment Summary
Resolving PRs:
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Aug 13, 2026
@deetergp two PRs were needed here. which do you think it most accurate for payment amount
@abbasifaizan70 @dmkt9 can you please accept the job below? Please reply here and tag me once you have. I can raise job price later, if needed.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
https://www.upwork.com/jobs/~022088003836253231780
abbasifaizan70 commentedon Aug 13, 2026
@mallenexpensify You again tagged me above wrongly.
dmkt9 commentedon Aug 14, 2026
@mallenexpensify Thanks. I've accepted the offer
nabi-ebrahimi commentedon Aug 14, 2026
@mallenexpensify, Accepted the offer, i think it should be $375. thanks.
mallenexpensify commentedon Aug 18, 2026
@MelvinBot two PRs were needed here. which do you think it most accurate for payment amount
$250 cuz the amount of work was expected
$375 cuz one was a followup (or the amount of work warrants an increase)
$500 cuz PRs are separate and should be $250 each.
MelvinBot commentedon Aug 18, 2026
I'd go with $375 (option 2).
Both PRs are by the same contributor (
nabi-ebrahimi, reviewed bydmkt9), and the second was a genuine followup on the same flow rather than a separate bug:openReport()rolls back the optimistic personal-detail record on failure. Fix missing participant email after failed chat creation #97557 retains that detail for failed new DMs and removes it on dismissal.Why not the other two options:
So it's more than the base scope but less than two full jobs — $375 is the fair middle. That matches what
nabi-ebrahimirequested above too.mallenexpensify commentedon Aug 18, 2026
Payment Summary
Contributor: @nabi-ebrahimi paid $375 via Upwork
Contributor+: @dmkt9 paid $375 via Upwork
^ Test case created. Thx
nabi-ebrahimi commentedon Aug 19, 2026
@mallenexpensify, thanks, please update the summay, i got paid. not @abbasifaizan70.
mallenexpensify commentedon Aug 19, 2026
Thx @nabi-ebrahimi , I blame GH for their shitty user recommendations. Apologies @abbasifaizan70 :/