Skip to content

[Due for payment 2026-09-16] [Follow-up] Restore the low-res → full-res transition for image receipts (and handle the infinite per-diem receipt load) #99199

Closed

Description

@MelvinBot

Background

PR #97313 improved hover-to-zoom quality for non-PDF (image) receipts by deferring image loading and rendering the original full-resolution receipt image. As part of that change, image receipts got a progressive low-res → full-res transition: the low-res preview was drawn semi-transparent with a loading indicator while the full-res original loaded, then it switched to the sharp full-res image.

That transition was later removed. PR #97313 caused a deploy blocker — #98587 (Per diem expense receipt loads infinitely after reset app). PR #98668 resolved the blocker by restoring ImageWithLoading to be byte-identical to production, which reverted the three rendering changes that produced the transition:

  • the preview being drawn with opacitySemiTransparent instead of full opacity
  • the removal of isThumbnailLoading
  • the spinner condition change (previewUri ? isLoading : isLoading && !isImageCached)

So today image receipts are back to the pre-#97313 rendering, and the low-res → full-res transition has not been added back.

Why it was reverted (the real root cause)

The infinite-loading regression was only exposed by #97313, not caused by it. The underlying bug is pre-existing: for some receipts the full-res .1024.jpg never emits onLoad or onError, so ImageWithLoading's isLoading state latches forever. On production ImageWithLoading stops showing the loading state once the low-res preview is on screen, so the latch renders as an ordinary thumbnail and nobody notices. #97313's semi-transparent-preview + permanent-spinner rendering made that latched state visible as an infinite loader (per-diem receipts after Clear cache and restart being one reproducible case).

What we want

Re-add the low-res → full-res progressive transition for image receipts (the intended UX from #97313), but in a way that does not reintroduce the infinite-loading regression — i.e. the loading state must not depend on the full-res image ever settling. Whoever picks this up should be able to reproduce the infinite per-diem receipt loading (steps in #98587) and confirm the new transition handles the never-onLoad/never-onError case gracefully (e.g. a timeout/fallback to the preview, or decoupling the spinner from the full-res load).

Relevant code

Reproducing the infinite per-diem receipt load

From #98587:

  1. Precondition: workspace has per diem rates.
  2. Create a per diem expense in a workspace chat.
  3. Account > Troubleshoot > Clear cache and restart > Reset and refresh.
  4. Go back to workspace chat and open the expense — the receipt should load (not spin forever).

Follow-up to #96999, requested in this comment.

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. mountiny commented on Aug 21, 2026

    @mountiny
    Contributor

    @bernhardoj do you want to work on this?

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 21, 2026
  3. MelvinBot commented on Aug 21, 2026

    @MelvinBot
    ContributorAuthor

    Proposal

    What is the root cause of that problem?

    Two things are tangled together here, so it helps to separate them.

    1. Why there's no transition today. PR #98668 restored ImageWithLoading to the production rendering, which brought back isThumbnailLoading (ImageWithLoading.tsx:57) and the spinner gate at ImageWithLoading.tsx:141. In this version the low-res preview is drawn at full opacity and the visible loading state is gated on the preview finishing (isThumbnailLoading), not on the full-res image finishing. So the low-res just gets silently swapped for the full-res with no "sharpening" cue.

    2. Why re-adding #97313's transition reintroduced the infinite loader. #97313 made the visible loading state (semi-transparent preview + spinner) depend on isLoading, which only clears when the full-res .1024.jpg emits onLoad or onError (see ImageWithLoading.tsx:126). For some receipts that image never emits either event (a still-generating derivative), so isLoading latches true forever — dimmed preview + permanent spinner. That latch is pre-existing; #97313 only made it visible. The per-diem-after-clear-cache case in #98587 is one reproducible instance.

    So the real constraint is: the visible loading/transition state must never depend on the full-res image settling, because it may never settle.

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

    Re-add the progressive transition in ImageWithLoading, but treat the low-res preview as the always-visible base layer and the full-res image as an overlay that fades in on its own onLoad:

    • Render the low-res preview immediately and keep it visible (full opacity) as soon as it loads — this is always a readable image and never depends on the full-res.
    • Layer the full-res image on top and transition it in (fade / opacity) when its own onLoad fires. If the full-res never fires onLoad/onError, the user is simply left looking at the readable low-res preview — no spinner latch, no infinite loader.
    • Gate any spinner strictly on the preview loading (isThumbnailLoading), never on the full-res isLoading. Keep the existing isThumbnailLoading reset in the waitForSession path (ImageWithLoading.tsx:135) so session-reload still behaves.

    This preserves the intended #97313 UX (low-res → sharp full-res) while making "never settles" a graceful no-op instead of an infinite loader. The wiring downstream is unchanged — previewUri already flows in from the thumbnail320 derivative at ReportActionItemImage.tsx:178 through ReceiptImage → DeferredImageWithLoading.

    Validating it: the current production code no longer shows the infinite loader (it was reverted), so you can't reproduce it as-is. To prove the new transition is safe, recreate the never-onLoad/never-onError condition — either follow the per-diem steps from #98587 while temporarily reintroducing #97313's rendering, or block/throttle the .1024.jpg request in devtools so its onLoad never fires — and confirm the receipt settles on the readable low-res instead of spinning.

    Alternative solutions considered

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/99199) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 21, 2026
  5. melvin-bot commented on Aug 21, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 21, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. huult commented on Aug 22, 2026

    @huult
    Contributor

    @bernhardoj do you want to work on this?

    @bernhardoj Let me know if you still want to implement this.

  8. bernhardoj commented on Aug 22, 2026

    @bernhardoj
    Contributor

    I can't reproduce the infinite loading (onLoad not firing), @huult if you can, go ahead!

  9. mukhrr commented on Aug 22, 2026

    @mukhrr
    Contributor

    @huult @bernhardoj I can reproduce this

    99199-perdiem-repro-web.mp4
  10. huult commented on Aug 23, 2026

    @huult
    Contributor
    Image

    Okay, I’ll check it soon.

  11. huult commented on Aug 24, 2026

    @huult
    Contributor

    After reinstalling, I can’t reproduce the issue on the latest main. @mukhrr, can you still reproduce it?”

  12. 93 remaining items

  13. melvin-bot commented on Sep 15, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Sep 15, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  15. melvin-bot commented on Sep 18, 2026

    @melvin-bot

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

  16. mallenexpensify commented on Sep 21, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @neerajbachani paid $250 via Upwork
    Contributor+: @huult due $250 via NewDot

    @neerajbachani can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022102169556596757023

  17. neerajbachani commented on Sep 21, 2026

    @neerajbachani
    Contributor

    @mallenexpensify I've accepted the job offer, thanks!!

  18. mallenexpensify commented on Sep 21, 2026

    @mallenexpensify
    Contributor

    @mallenexpensify paid, summary updated above. Thx.

  19. JmillsExpensify commented on Oct 14, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @huult

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 productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions