Skip to content

[$175] Receipt retention bug #106153

Open
0 of 14 issues completed
Open

Description

@mountiny

Customer report

A customer using New Expensify reports that receipts are intermittently missing after they add them, and that expense descriptions are being erased. They now retain separate copies of their receipts because they do not trust capture to persist reliably.

These are customer-reported symptoms, not yet reproduced or independently verified. It is not yet known whether the receipts fail to upload, fail to sync, become detached, or are simply not displayed. It is also unknown whether the description loss shares the same cause.

Expected behavior

Receipts added to expenses remain accessible, and saved descriptions persist unless explicitly changed or removed.

Investigation

  • Review the affected sessions and available receipt-upload/sync telemetry through an appropriately private channel.
  • Establish the capture method, device/OS, app version, connectivity state, and timing of an affected attempt.
  • Trace an affected receipt from capture through upload, expense creation, and subsequent updates to identify where it stops being accessible.
  • Investigate which operation clears the description and whether it is related to the receipt symptom.
  • Record verified reproduction steps and scope; add regression coverage once the cause is established.

Known limitations

No reproduction steps, affected expense/receipt IDs, session timestamps, or confirmed root cause are available in this sanitized report. Default platform was reported as New Expensify; the exact client is unconfirmed.

Privacy

Customer names, email addresses, company information, account identifiers, customer quotes, and links to customer records or identifying source material are intentionally omitted.

Issue OwnerCurrent Issue Owner: @rinej
Upwork Automation - Do Not Edit

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 5, 2026
  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 5, 2026
  3. melvin-bot commented on Nov 5, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

  4. changed the title [-]Receipt retention bug[/-] [+][$175] Receipt retention bug[/+] on Nov 5, 2026
  5. melvin-bot commented on Nov 5, 2026

    @melvin-bot
  6. vanshshah11 commented on Nov 6, 2026

    @vanshshah11

    Proposal

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

    Customers on New Expensify report that receipts attached to expenses intermittently disappear, and that expense descriptions (comments) get erased. No reproduction exists yet — the failure is intermittent and the affected sessions were not captured. We need the actual root cause, verified reproduction steps, and a fix.

    What is the root cause of that problem?

    I've traced the write paths, and I believe both symptoms share one mechanism: when a queued transaction write gives up after exhausting retries, its failureData reverts the entire transaction snapshot captured at queue time — wiping out any receipt/description changes that were made after that write was queued.

    The chain:

    1. updateMoneyRequestDescription, updateMoneyRequestMerchant, etc. all build their failure revert in getUpdateMoneyRequestParams (src/libs/actions/IOU/UpdateMoneyRequest.ts:2323-2333) as a whole-object snapshot: value: {...transaction, pendingFields: clearedPendingFields, ...}. Note the asymmetry — pendingFields is carefully field-scoped (getUpdatedTransaction.ts:45), but the value revert is not.
    2. SequentialQueue fires that revert on retry exhaustion (src/libs/Network/SequentialQueue.ts:580-601 — "Request failed too many times, giving up" → Onyx.update(requestToProcess.failureData)).
    3. There is no conflict dedup for UPDATE_MONEY_REQUEST_* commands — RequestConflictUtils.ts only matches OpenReport/reconnect/comment/policy commands — so a description edit and a merchant edit on the same expense queue as independent entries, each carrying its own full-snapshot revert.

    So the customer scenario is: edit a field (merchant/amount) while flaky-networked → queue backs up → user then adds a receipt and edits the description (optimistic merges land locally) → the original write fails permanently and exhausts retries → its failureData merges the stale snapshot back over the transaction → description reverts to the old value and the receipt reverts to whatever existed before (or null) — both reported symptoms in one mechanism.

    Two adjacent contributors for the receipt-specific symptom:

    • replaceReceipt's failureData (src/libs/actions/IOU/Receipt.ts:328-348) reverts receipt to oldReceipt ?? null — when a first-ever receipt attach gives up, the receipt silently becomes null (only a logReceiptGaveUp telemetry line, invisible to the user).
    • ReceiptUploadRetryHandler (src/libs/ReceiptUploadRetryHandler/index.ts:81-84) gives up permanently if the local file was evicted mid-retry-window — no recovery path.

    This explains the intermittency (requires failure + retry exhaustion), why it survives app restarts (queue is persisted via PersistedRequests.ts), and why the customer "no longer trusts capture to persist."

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

    1. Make the failure revert field-scoped: in getUpdateMoneyRequestParams, revert only the fields the command actually changed (mirror getClearedPendingFields), instead of spreading the whole queued snapshot. This is the core fix.
    2. Add conflict dedup for UPDATE_MONEY_REQUEST_* commands keyed on transactionID (coalesce queued updates for the same transaction to the latest, following the existing checkAndFixConflictingRequest pattern) so multiple independent full-snapshot reverts can't interleave.
    3. For the receipt path: when a first-ever receipt attach gives up, surface a user-visible error state on the expense instead of silently nulling.

    What specific scenarios should be covered by automated tests?

    • Offline queue: edit merchant → add receipt → edit description → merchant write fails with retry exhaustion → assert description and receipt survive (currently they would revert).
    • First-ever REPLACE_RECEIPT retry exhaustion → assert receipt state and user-visible error.
    • Two queued UPDATE_MONEY_REQUEST_* for the same transactionID → assert no stale-snapshot clobber after one fails.
    • Onyx merge semantics: whole-object snapshot revert vs field-scoped revert unit test.

    What alternative solutions did you explore?

    • Server-side push overwrite (OnyxUpdates.ts flat merges): possible for the description symptom when two clients are involved, but doesn't explain receipt disappearance — kept as secondary diagnostic.
    • ReceiptStorage eviction alone: explains receipts only, not descriptions. The unified failureData mechanism explains both and matches "intermittent" precisely.

    Investigation plan (the issue's checkboxes)

    1. Verify merge semantics of the whole-snapshot revert against react-native-onyx's MERGE contract (code).
    2. Reproduce locally: force-offline, queue merchant→description→receipt writes, fail the merchant command with a 500, observe the clobber via Onyx devtools.
    3. Mine logReceiptGaveUp + "Request failed too many times" telemetry for transactionIDs with 2+ queued UPDATE_MONEY_REQUEST commands followed by the symptom.
    4. Confirm the fix (field-scoped revert + dedup) against the reproduction.

    PR

    PR will be linked here once created.

  7. vanshshah11 commented on Nov 6, 2026

    @vanshshah11

    Contributor details
    Your Expensify account email: svansh1111@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01b6a593fd295a20bf

  8. melvin-bot commented on Nov 6, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  9. 6 remaining items

  10. mountiny commented on Nov 10, 2026

    @mountiny
    ContributorAuthor

    @rinej @adhorodyski there are still a bunch of reviews by customers coming in, reporting various issues with the receipts retention. Let's keep on going through the logs and full story sessions to try to identify the flows where we might be missing the receipts

  11. mountiny commented on Nov 10, 2026

    @mountiny
    ContributorAuthor
  12. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    @rinej Huh... This is 4 days overdue. Who can take care of this?

  13. adhorodyski commented on Nov 13, 2026

    @adhorodyski
    Contributor

    Not overdue, investigating it. I'll post an update in Slack on my findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorOverdue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions