Skip to content

[Due for payment 2026-06-08] Receipt loading is slow and should be faster #85875

Closed

Description

@marcaaron

Problem

When you open an expense, the receipt image is slow to load. After you capture a receipt and submit an expense, the image displays instantly from your local file - but once the API responds, the server sends back a remote URL which overwrites the local file path in Onyx. The app then has to download the exact same image it just uploaded, complete with auth headers, causing a loading spinner to appear for something the device already has.

Solution

A few angles to explore:

  • After the server responds and sets receipt.source to the remote URL, preserve the local file:// path in the client-side success data so Onyx doesn't get steamrolled by the server's version.
  • Alternatively, pre-populate the image cache with the local file bytes keyed to the remote URL, so the "download" is effectively instant.
  • Reduce the resolution/quality of images we store in general. Receipts might not necessarily need to be full camera resolution - a smaller file that's still readable would load much faster for everyone, not just on the device that took the photo (looking into this in parallel here).
  • As a separate improvement, we could show a low-res thumbnail immediately while the full image loads in the background for cases where the image genuinely needs to be fetched (e.g., viewing on a different device).
Issue OwnerCurrent Issue Owner: @Eskalifer1

Activity

  1. added
    Daily
    Hot Pick
    and removed
    Daily
    on Mar 19, 2026
  2. samranahm commented on Mar 19, 2026

    @samranahm
    Contributor

    Proposal

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

    Receipt loading is slow and should be faster

    What is the root cause of that problem?

    When a scan expense is created, the optimistic transaction stores a local receipt URI (file:// or blob:), which renders instantly. After the API succeeds, server Onyx updates include a remote receipt URL and overwrite transaction.receipt.source. That forces a re-download (with auth), so the receipt briefly shows a loader even though the same bytes already exist locally.

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

    We should keep the local receipt URI on success for scan requests, so UI continues using the already-available local file instead of immediately switching to remote URL and re-fetching.

    1. Add shouldPreserveLocalReceiptSource in buildOnyxDataForMoneyRequest
    const shouldPreserveLocalReceiptSource = isScanRequest && isLocalFile(transaction.receipt?.source);

    and add it with

          pendingFields: clearedPendingFields,
          ...(shouldPreserveLocalReceiptSource ? {receipt: {source: transaction.receipt?.source}} : {}),
          // The routes contains the distance in meters. Clearing the routes ensures we use the distance
          // in the correct unit stored under the transaction customUnit once the request is created.
          // The route is also not saved in the backend, so we can't rely on it.
          routes: null,
      },
    },

    here

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
    value: {
    pendingAction: null,
    pendingFields: clearedPendingFields,
    // The routes contains the distance in meters. Clearing the routes ensures we use the distance
    // in the correct unit stored under the transaction customUnit once the request is created.
    // The route is also not saved in the backend, so we can't rely on it.
    routes: null,
    },
    },

    and implement the same in buildOnyxDataForTrackExpense

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  3. moved this from HIGH to CRITICAL in [#whatsnext] #qualityon Mar 20, 2026
  4. sosek108 commented on Mar 23, 2026

    @sosek108
    Contributor

    Hi, I'm Hubert from callstack and I can work on this issue

  5. melvin-bot commented on Mar 23, 2026

    @melvin-bot

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

  6. sosek108 commented on Mar 24, 2026

    @sosek108
    Contributor

    @marcaaron Noone is assigned to this issue. Who should decide whether contributor or me should work on this issue?

  7. sosek108 commented on Mar 25, 2026

    @sosek108
    Contributor

    adding changes only in optimisticData and/or successData is not sufficient because on OpenReport application will try to replace local url with server side URL and we will see this artefact:

    first_attempt.mov

    After we open created report the image disappears for a brief moment this may be caused because of Onyx:

    1. store optimistic update
    2. store server update (write to source)
    3. store succes update (write to source again)
  8. melvin-bot commented on Mar 25, 2026

    @melvin-bot

    Eep! 4 days overdue now. Issues have feelings too...

  9. 65 remaining items

  10. Eskalifer1 commented on Jun 3, 2026

    @Eskalifer1
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      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.

    Regression Test Proposal Template

    Regression Test Proposal

    Precondition:

    • You should start testing on freshly logged in account and the best experience should be in incognito mode

    Test:

    1. Go to Spend page -> Transactions
    2. Open one of Transaction with receipt
    3. Observe if low res image is present for the moment a target image is loaded

    Note: this fix aims primarily to improve performance for desktop web. It adds the functionality to iOS and Android platform but due to other factors the performance gain is not always visible.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-f7ff-ab0e-0727-ada93ff80cd4
  11. Eskalifer1 commented on Jun 3, 2026

    @Eskalifer1
    Contributor

    Just a heads-up: I'll be OOO from June 5 through June 14 and won't be available to review or follow up on this issue during that time.

  12. added
    Weekly
    Daily
    Awaiting Payment
    and removed
    Daily
    Weekly
    on Jun 3, 2026
  13. melvin-bot commented on Jun 7, 2026

    @melvin-bot

    Current assignee @mallenexpensify is eligible for the Awaiting Payment assigner, not assigning anyone new.

  14. mallenexpensify commented on Jun 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Eskalifer1 paid $250 via Upwork.

    @Eskalifer1 when you're back.... can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022064076372489569567

  15. Eskalifer1 commented on Jun 9, 2026

    @Eskalifer1
    Contributor

    I was able to accept it today, thank you!

    cc: @mallenexpensify

  16. mallenexpensify commented on Jun 9, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

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

Metadata

Metadata

Labels

Awaiting PaymentDailyEngineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions