Skip to content

[Due for payment 2026-07-23] Improve receipt durability and observability when upload fails #92139

Closed
1 of 1 issue completed

Description

@MelvinBot

Problem

In rare cases, receipts captured in NewDot can fail to upload and end up effectively lost — the user is left without a clear way to recover the image. A recent investigation suggested this can happen when something blocks the write queue between capture and a sign-out (or other lifecycle event), but we currently lack the observability to confirm the exact sequence in production. We're left guessing at what happened in individual cases.

Two related concerns:

  1. Receipt durability — once a user has taken a photo of a receipt inside the app, we should make it very hard for that image to be lost, even if the upload pipeline fails.
  2. Observability — when this does happen, we don't have enough logs to diagnose the root cause after the fact.

Proposals discussed

Option 1 — Save the receipt to the device's photo library on capture.

  • Pros: Simple, gives the user a clear recovery path (re-submit from gallery).
  • Cons: Requires photo library permission. Doesn't work if the user has denied that permission.

Option 2 — Persist the captured receipt in a dedicated local queue/store, and on next sign-in by the same user, prompt them to resubmit if anything is still pending.

  • Pros: Better UX. No extra OS permission needed. Doesn't rely on the user having access to the photo library.
  • Cons: If we persist images as base64 in Onyx, they'd remain on disk after sign-out in an unencrypted form. We don't currently encrypt anything at rest in Onyx, so this is arguably consistent with our current model — but it raises the bar of what's accessible to a technical user after sign-out. We'd want to think carefully about scope-down/cleanup behavior here.

Observability work

Independently of which recovery approach we pick, we need to substantially improve logging in the receipt capture → upload → SmartScan flow so that when a customer reports a lost receipt, we can:

  • Confirm whether the image was captured.
  • Confirm whether the upload request was enqueued.
  • Confirm whether/when it was sent, and what the server response was.
  • Confirm queue state at sign-out / app close / app foreground events.

The goal: when a similar report comes in, we should be able to answer "what happened" from logs rather than guessing.

Related

There was also a side discussion about doing a SmartScan queue (SQ) audit, similar to the prior offline-tracking audit, and documenting the findings in a doc analogous to NETWORK_STATE_DETECTION.md. That work is likely tracked separately, but is referenced here for context.

Suggested next steps

  • Decide between Option 1, Option 2, or a hybrid (e.g., photo library when permission is granted, fall back to local queue otherwise).
  • Define the cleanup/scope-down rules for any locally persisted receipt images.
  • Add structured logs at each step of the capture → upload → scan pipeline, plus lifecycle events (sign-out, background, foreground).

Slack thread: https://expensify.slack.com/archives/C05LX9D6E07/p1779949397375439

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. moved this from HIGH to CRITICAL in [#whatsnext] #qualityon May 30, 2026
  2. melvin-bot commented on Jun 2, 2026

    @melvin-bot

    @adhorodyski Whoops! This issue is 2 days overdue. Let's get this updated quick!

  3. melvin-bot commented on Jun 4, 2026

    @melvin-bot

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

  4. adhorodyski commented on Jun 8, 2026

    @adhorodyski
    Contributor

    Not overdue, this PR is in motion and I'm already working on a SQ audit 👍🏼

  5. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    @adhorodyski Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  6. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    @adhorodyski Still overdue 6 days?! Let's take care of this!

  7. adhorodyski commented on Jun 16, 2026

    @adhorodyski
    Contributor

    Wrapped up most SQ related topics and going back to this one now, I'll update as soon as I have something.

  8. 56 remaining items

  9. mallenexpensify commented on Jul 28, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @mkhutornyi due $500 via NewDot

  10. rinej commented on Jul 29, 2026

    @rinej
    Contributor

    I checked, and you're right - we missed that. It looks like it was reverted because of this issue with permission storage modal: #95957

    The logging implementation itself is already merged and looks solid.

    I'll wrap up my current tasks and start working on re-implementing the v2

  11. mountiny commented on Jul 29, 2026

    @mountiny
    Contributor

    Thanks

  12. mallenexpensify commented on Jul 30, 2026

    @mallenexpensify
    Contributor

    Cool to close?!??!

  13. rinej commented on Jul 30, 2026

    @rinej
    Contributor

    @mountiny do we need new ticket for the follow up? There will be just the following part of it:

    Problem: When a user signs out on iOS/Android while a receipt is still queued for upload (e.g. offline), the pending receipt is lost.
    Solution: If a user signs out while a receipt is still uploading, save that receipt image to the device gallery before storage is cleared, and show a confirmation modal with the prompt.

  14. mountiny commented on Jul 30, 2026

    @mountiny
    Contributor

    @MelvinBot can you create a new issue with:

    Problem: When a user signs out on iOS/Android while a receipt is still queued for upload (e.g. offline), the pending receipt is lost.
    Solution: If a user signs out while a receipt is still uploading, save that receipt image to the device gallery before storage is cleared, and show a confirmation modal with the prompt.

    Assign @rinej @mountiny and @eVoloshchak as a follow up

  15. MelvinBot commented on Jul 30, 2026

    @MelvinBot
    ContributorAuthor

    🤖 Created the follow-up issue: #97487

    Assigned rinej, mountiny, and eVoloshchak.

  16. rinej commented on Jul 31, 2026

    @rinej
    Contributor

    created follow up PR -> #97562

  17. trjExpensify commented on Aug 3, 2026

    @trjExpensify
    Contributor

    approved $500 for @mkhutornyi

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionReviewingHas a PR in reviewTaskWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions