Repository navigation
Description
Receipts captured while offline or on a weak connection wait in an upload queue until the network recovers. Onyx.clear() empties that queue, and eleven session-teardown paths call it. We already log a [Receipt] namespace covering capture, submit, enqueue, and drop-on-missing-file, plus a queue snapshot at sign-out and at backgrounding. Over five days in early August, 4–5 users per day signed out while receipts were still queued, and those receipts disappeared.
Problem
When a receipt is destroyed, we don't know the specific reason why. That makes the issue hard to track and hard to fix, and we have no accurate statistics on which path is the most harmful.
We do now show a modal warning users who manually sign out with receipts still queued, and the logs confirm it fires correctly. But it only covers the manual sign-out path. Other paths trigger the sign-out flow, and today we can't tell which one caused a loss.
Solution
Put enough detail on every loss to name its specific cause.
- Give each of the eleven paths a value in a
CONST.SIGN_OUT_REASONconstant, and make it a required first argument ofredirectToSignIn. - Widen the queue snapshot line. It already exists and already names the receipt, but it can't point to a specific path. Every pending receipt gains six fields:
reason,snapshotID,pendingReceiptCount,msSinceEnqueued,isSourceInDurableFolder,platform. - Log the one loss that happens while the user is still signed in. When the queue abandons a receipt-bearing request after exhausting retries, emit a
gaveUpevent with the trace id. Cancelled and duplicate-record discards stay silent — the sign-out snapshot already covers the first, and nothing is lost in the second. - On the existing
droppedline, carry thestat()error code so the reason a file went missing arrives already joined to the capture. Sentry gets the code but not the raw message, which contains the file path.
Outcome
In the best case we confirm sign-out is not the main cause of the remaining lost receipts. If it is, we'll know which path triggered it and have enough context to find the proper fix.
Scope
This does not stop receipts from being lost. Stopping the loss is a separate effort already in progress.
Draft PR: #99065
Reported in Slack.
Issue Owner
Current Issue Owner: @mallenexpensifyMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Sep 15, 2026
@mountiny @rinej
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.78-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
5 remaining items
melvin-bot commentedon Sep 17, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)Eskalifer1 commentedon Sep 17, 2026
Oh, totally missed that one!
Eskalifer1 commentedon Sep 17, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A - new feature
[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: N/A
[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.
I don't think it's worth adding test here, since it's just logging. But if you have other opinion lmk!
melvin-bot commentedon Sep 17, 2026
Payment Summary
Resolving PRs:
Make receipt loss attributable to the path that caused it #99065
Contributor: @rinej does not require payment (Contractor)
Assignee: @Eskalifer1 requires payment (Needs manual offer from BZ)
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Sep 21, 2026
Payment Summary
Contributor+: @Eskalifer1 paid $250 via Upwork
@Eskalifer1 can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022102185761303745707
Eskalifer1 commentedon Sep 22, 2026
Hi @mallenexpensify, i have accepted, thank you!
mallenexpensify commentedon Sep 22, 2026
@Eskalifer1 paid, summary updated above. Thx.