Skip to content

Fix receipt full-res image not loading when preview displaces it in flow - #100423

Open
neerajbachani wants to merge 1 commit into
Expensify:mainfrom
neerajbachani:fix/99199-receipt-fullres-onload
Open

Fix receipt full-res image not loading when preview displaces it in flow#100423
neerajbachani wants to merge 1 commit into
Expensify:mainfrom
neerajbachani:fix/99199-receipt-fullres-onload

Conversation

@neerajbachani

@neerajbachani neerajbachani commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

While isLoading is true, ImageWithLoading renders the low-res preview and full-res image as two in-flow siblings inside a clipped receipt container. On web, the preview pushes the full-res <img> below the visible box, so lazy loading never decodes it, onLoad never fires, and the receipt can stay on the blurry preview or show an infinite spinner.

This change positions the preview absolutely so it overlays the receipt box instead of displacing the full-res image. The full-res image remains the only in-flow child, stays inside the clip rect, and loads normally with loading="lazy" unchanged.

Fixed Issues

$ #99199
PROPOSAL: #99199 (comment)

Tests

  1. Open a workspace with per diem rates configured
  2. Create a per diem expense with an image receipt in the workspace chat
  3. Go to Account → Troubleshoot → Clear cache and restart → Reset and refresh
  4. Reopen the chat containing the per diem expense
  5. Verify the receipt transitions from the low-res preview to the sharp full-res image and the loading spinner clears
  6. Verify other image receipts in the same report also load full resolution correctly
  7. Open the same receipt from the expense details/attachment view and verify it still loads correctly
  8. Scroll through a long report with multiple receipts and verify below-the-fold receipts still load after scrolling into view
  • Verify that no errors appear in the JS console

Offline tests

  1. Open a chat with image receipts while online and wait for receipts to load
  2. Go offline
  3. Reopen the chat
  4. Verify previously loaded receipts still display and no unexpected errors appear in the console

QA Steps

  1. Open a workspace with per diem rates configured
  2. Create a per diem expense with an image receipt in the workspace chat
  3. Go to Account → Troubleshoot → Clear cache and restart → Reset and refresh
  4. Reopen the chat containing the per diem expense
  5. Verify the receipt shows the low-res preview briefly, then transitions to the sharp full-res image without an infinite spinner
  6. Verify other image receipts in the report load full resolution correctly
  7. Verify opening the receipt from expense details still works as expected
  8. Verify no errors appear in the JS console
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-09-05.at.12.21.54.AM.online-video-cutter.com.mp4

@neerajbachani
neerajbachani requested review from a team as code owners September 4, 2026 18:40
@melvin-bot
melvin-bot Bot requested review from huult and removed request for a team September 4, 2026 18:40
@melvin-bot

melvin-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

@huult Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from flaviadefaria and removed request for a team September 4, 2026 18:40
@huult

huult commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@neerajbachani Could you restore the behavior that was reverted due to the issue? Since the issue is fixed now, please restore it together with the fix in this PR.

…transition UX

Position the preview out of flow so the full-resolution image is not
pushed below the clipped receipt box on web. Revert the Expensify#98668
isThumbnailLoading workaround and restore Expensify#97313's dim preview and
spinner tied to isLoading now that full-res onLoad fires reliably.
@neerajbachani
neerajbachani force-pushed the fix/99199-receipt-fullres-onload branch from 8ec0490 to 9de0979 Compare September 6, 2026 06:00
@neerajbachani

Copy link
Copy Markdown
Contributor Author

@huult Done — restored #97313's dim preview and spinner tied to isLoading (reverted the #98668 isThumbnailLoading workaround) alongside the pAbsolute layout fix. Re-tested with your repro steps; full-res loads and spinner clears.

@huult

huult commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-09-06.at.15.16.58.mov
Android: mWeb Chrome
Screen.Recording.2026-09-06.at.15.14.51.mov
iOS: HybridApp
Screen.Recording.2026-09-06.at.15.19.51.mov
iOS: mWeb Safari
Screen.Recording.2026-09-06.at.15.21.17.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-06.at.15.09.25.mov

@huult

huult commented Sep 6, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-09-06.at.13.08.36.mov

@neerajbachani Could you check why the spinner is still showing and never disappears when the report is empty in this PR?

@neerajbachani

Copy link
Copy Markdown
Contributor Author

@huult I checked this on upstream main (not my PR branch) and can reproduce the same infinite spinner on an empty report after clear cache and restart — so I don't think this is caused by my PR changes.

My PR diff vs main is only the preview style line (pAbsolute + opacitySemiTransparent); spinner gating is the same as main (isThumbnailLoading). If the empty-report spinner also happens on main, it looks like a separate pre-existing issue.

Could you verify on your side that we’re seeing the same thing on main? If we’re aligned, I’ll investigate that separately and can open a dedicated PR for it — keeping this PR scoped to the #99199 layout fix.

@huult

huult commented Sep 6, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-09-06.at.13.35.31.mov

@neerajbachani Yes, I can reproduce it on staging, so I can confirm that it is not related to this PR and should be tracked as a separate issue. Thanks for checking! I posted it in Slack.

@neerajbachani

Copy link
Copy Markdown
Contributor Author

@huult Found and fixed the infinite spinner on empty workspace chat (separate from the receipt issue in #100423).

Root cause
After cache clear + restart, hasOnceLoadedReportActions resets. On reopen, ReportFetchHandler sets it again before openReport resolves - so the preview carousel in MoneyRequestReportPreviewProvider sees a stale "still loading" flag and spins forever, even when total === 0 and nothing is actually in flight.

Screen.Recording.2026-09-06.at.11.45.09.AM.online-video-cutter.com.mp4

Fix
Aligned the preview's loading gate with the same logic the rest of the money-request UI uses -shouldWaitForTransactions + useIsReportLoadPending. For a confirmed-empty report, we skip the stale RAM flag when openReport isn't in flight. Empty state renders correctly.

Verified locally with your exact repro (clear cache → reopen workspace chat):

Screen.Recording.2026-09-06.at.12.32.04.PM.online-video-cutter.com.mp4

@flaviadefaria since this is a distinct bug from #99199, I'd like to open a dedicated PR for it and keep #100423 scoped to the receipt fix only. Good to proceed?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants