Skip to content

feat: render high-res PDF overlay on receipt hover zoom - #93583

Merged
mountiny merged 2 commits into
Expensify:mainfrom
software-mansion-labs:fix/improve-pdf-receipt-zoom-quality
Jun 17, 2026
Merged

mountiny merged 2 commits into
Expensify:mainfrom
software-mansion-labs:fix/improve-pdf-receipt-zoom-quality

Conversation

@WojtekBoman

@WojtekBoman WojtekBoman commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

PDF receipts are served as low-resolution JPG thumbnails by the server. When hover-zoomed, these thumbnails blur because the zoom is applied to an upscaled raster. This PR adds ReceiptZoomablePDF — a web-only component that renders the actual PDF at 2.5× its on-screen size (then scales it back down with CSS), so the hover-zoom layer reveals real PDF pixels. A native no-op stub keeps bundling clean. HOVER_ZOOM_SCALE is extracted to CONST.RECEIPT so both components share the value.

Screen.Recording.2026-06-15.at.14.50.47.mov

Fixed Issues

$ #93627
PROPOSAL:

Tests

Tests should be performed on web platforms

  1. Open a report that has a PDF receipt attached (non-local, uploaded to server).
  2. On web (Chrome/Safari desktop), hover over the receipt thumbnail in the report action item.
  3. Verify that the hover-zoom magnification shows sharp, readable PDF text — not a blurry upscaled image.

  1. Open a report with a PDF receipt as above.
  2. Disconnect from the network (or block the PDF URL in DevTools Network tab) so the PDF fails to load.
  3. Hover over the receipt thumbnail.
  4. Verify that the JPG thumbnail is still visible underneath (no blank area) and no JS errors appear in the console.

  1. Open a report with a non-PDF receipt (JPG/PNG image).
  2. Hover over the receipt thumbnail.
  3. Verify that hover-zoom behaviour is unchanged — no PDF overlay is rendered, no regressions.
  • Verify that no errors appear in the JS console

Offline tests

This component fetches the PDF via the server URL. Offline behavior is covered in test 2 above: when the PDF URL is unreachable, onLoadError fires, hasFailed is set to true, and ReceiptZoomablePDF renders null, revealing the pre-loaded JPG thumbnail underneath. No new Onyx writes are involved.

QA Steps

Same as tests

  • 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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

@codecov

codecov Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/CONST/index.ts 93.84% <ø> (ø)
...nents/ReportActionItem/MoneyRequestReceiptView.tsx 69.51% <100.00%> (ø)
src/components/ReceiptHoverZoom/index.web.tsx 0.00% <0.00%> (ø)
...eportActionItem/ReceiptPDFOverlay/index.native.tsx 0.00% <0.00%> (ø)
...ponents/ReportActionItem/ReportActionItemImage.tsx 69.35% <77.77%> (+2.08%) ⬆️
...nents/ReportActionItem/ReceiptPDFOverlay/index.tsx 0.00% <0.00%> (ø)
... and 179 files with indirect coverage changes

@WojtekBoman
WojtekBoman force-pushed the fix/improve-pdf-receipt-zoom-quality branch from 2f6ce38 to cca40dd Compare June 15, 2026 12:48
@WojtekBoman

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: cca40dd454

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@WojtekBoman
WojtekBoman marked this pull request as ready for review June 15, 2026 14:29
@WojtekBoman
WojtekBoman requested review from a team as code owners June 15, 2026 14:29
@melvin-bot
melvin-bot Bot requested review from madmax330 and trjExpensify and removed request for a team June 15, 2026 14:29
@melvin-bot

melvin-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

@madmax330 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]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cca40dd454

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@madmax330

Copy link
Copy Markdown
Contributor

@WojtekBoman can you update the fixed issue and assign the c+ for review?


const TRANSPARENT_BACKGROUND = {backgroundColor: 'transparent'} as const;

const {HOVER_ZOOM_SCALE} = CONST.RECEIPT;

@ZhenjaHorbach ZhenjaHorbach Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this format? 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored!

@github-actions

Copy link
Copy Markdown
Contributor

🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here.

* amount + waypoints) should be shown. A merged distance expense can be typed `distance-manual` yet
* still carry waypoints, so the presence of waypoints keeps those included.
*/
function isMapBasedDistanceRequest(transaction: OnyxEntry<Transaction>): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add tests for this

Comment thread src/libs/TransactionUtils/index.ts Resolved
@github-actions

This comment has been minimized.

@WojtekBoman
WojtekBoman force-pushed the fix/improve-pdf-receipt-zoom-quality branch from cca40dd to 024c390 Compare June 16, 2026 07:19
@melvin-bot
melvin-bot Bot requested a review from mountiny June 16, 2026 09:31
@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

But only one comment
For big PDFs, we have a noticeable delay when switching to high-res PDF
But it's okat I think

2026-06-16.11.39.12.mov

@WojtekBoman

Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach I'll take a look at these issues 👀

@mountiny

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach Can you check how the same PDF behaves in OldDot? I agree that we might not be able to make this super smooth for large PDF

@ZhenjaHorbach

ZhenjaHorbach commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

We just have a delay after hovering / before zooming in OD
But in my opinion, this is even worse than now in this PR

2026-06-16.23.00.52.mov

trjExpensify
trjExpensify previously approved these changes Jun 16, 2026

@trjExpensify trjExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement. 👍

@mountiny

Copy link
Copy Markdown
Contributor

@WojtekBoman How its looking?

@WojtekBoman

WojtekBoman commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor Author

There are 4 problems found by @ZhenjaHorbach:

I think this one is worth to check before we merge it, but I'd like to confirm it's a problem:

Should this be adjusted in this PR? Should any of the other issues be addressed in this PR? cc: @mountiny @ZhenjaHorbach

@ZhenjaHorbach

ZhenjaHorbach commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

There are 4 problems found by @ZhenjaHorbach:

I think this one is worth to check before we merge it, but I'd like to confirm it's a problem:

Should this be adjusted in this PR? Should any of the other issues be addressed in this PR? cc: @mountiny @ZhenjaHorbach

Yes
The first 3 are minor or not related to this PR


But regarding the last issue, we need to decide how best to fix it first
But I don't mind fixing it in a separate PR!


And this issue we have in staging also
So we can definitely fix this in a separate PR

@mountiny

Copy link
Copy Markdown
Contributor

zoom works incorrectly while scanning receipts #93583 (comment)

So it does not zoom until the pdf is scanned and synced with the server?

@WojtekBoman

Copy link
Copy Markdown
Contributor Author

zoom works incorrectly while scanning receipts #93583 (comment)

So it does not zoom until the pdf is scanned and synced with the server?

Yes, but already changed that, now it's allowed to zoom while scanning, it was easy and safe change so added it. @ZhenjaHorbach Could you check if it's ok now?

@ZhenjaHorbach

ZhenjaHorbach commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

zoom works incorrectly while scanning receipts #93583 (comment)

So it does not zoom until the pdf is scanned and synced with the server?

Yes, but already changed that, now it's allowed to zoom while scanning, it was easy and safe change so added it. @ZhenjaHorbach Could you check if it's ok now?

By the way
Here, I mentioned a bug that the default scale is incorrect (without zooming) 😅

Снимок экрана — 2026-06-17 в 13 29 06 vs Снимок экрана — 2026-06-17 в 13 29 11

But yes
It's good that we fixed the bug with the disabled zoom while scanning also

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we can move this ahead now then

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

zoom works incorrectly while scanning receipts #93583 (comment)

So it does not zoom until the pdf is scanned and synced with the server?

Yes, but already changed that, now it's allowed to zoom while scanning, it was easy and safe change so added it. @ZhenjaHorbach Could you check if it's ok now?

By the way, we can now also zoom images while scanning
But that's probably okay

@mountiny
mountiny merged commit a38b04d into Expensify:main Jun 17, 2026
42 of 43 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify OSBotify mentioned this pull request Jun 17, 2026
67 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.10-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no docs changes required

I reviewed the changes in this PR against the help articles under docs/articles, and no help-site updates are needed.

Why: This PR is a behind-the-scenes rendering-quality improvement. It adds a web-only ReceiptPDFOverlay that renders the real PDF (oversampled then CSS-scaled) on top of the existing JPG thumbnail so the hover-zoom magnification of remote PDF receipts shows sharp pixels instead of a blurry upscaled raster. It introduces:

  • No new user-facing feature, button, tab, setting, or workflow
  • No change to any documented procedure (attach, crop, rotate, add additional receipts)
  • A pure visual fidelity improvement to an existing interaction

The hover-zoom magnification behavior itself is not documented in the help site today, and a sharpness/quality fix to an existing visual interaction isn't the kind of change that warrants a help article. The closest article — Attach-and-edit-receipts-on-expenses.md — describes attaching, cropping, and rotating receipts, none of which are affected by this change.

Since no docs changes are required, I have not created a draft PR.


@WojtekBoman, please confirm you agree no help-site changes are needed here. If you think a particular article should still be updated, let me know which one and I'll open a draft PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.12-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes and no help site updates are required under App/docs/articles.

Why: This PR is an under-the-hood rendering-quality improvement. It adds a web-only ReceiptZoomablePDF overlay so that PDF receipt thumbnails reveal sharp PDF pixels when hover-zoomed, instead of a blurry upscaled JPG. It introduces no new feature, setting, tab, button, or user-facing workflow — the hover-zoom magnification behavior is the same as before, just sharper for PDFs.

I checked the help articles (including Attach-and-edit-receipts-on-expenses.md) and the receipt hover-zoom magnification is not documented, so there is nothing to update.

No draft PR was created since no documentation changes are needed.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.14-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@IuliiaHerets

Copy link
Copy Markdown

Hi @WojtekBoman. Can it be tested on the Native apps?

cc @mountiny @trjExpensify @madmax330 @ZhenjaHorbach

@WojtekBoman

Copy link
Copy Markdown
Contributor Author

@IuliiaHerets No, native apps aren't supported for this. I will update the PR description!

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.4.14-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

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.

8 participants