Skip to content

Add page navigation to multi-page PDF receipts - #102776

Open
ishpaul777 wants to merge 35 commits into
Expensify:mainfrom
ishpaul777:ishpaul-102435-pdf-page-nav
Open

ishpaul777 wants to merge 35 commits into
Expensify:mainfrom
ishpaul777:ishpaul-102435-pdf-page-nav

Conversation

@ishpaul777

@ishpaul777 ishpaul777 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Multi-page PDF receipts showed a static "Page 1 of N" badge, and there was no way to flip pages in the expense's receipt preview. On desktop, that preview already draws the real PDF over the page 1 thumbnail so hover zoom stays sharp. This PR turns the badge into a pill with previous/next buttons that change which page that layer shows.

For multi-page PDFs the layer now renders only the current page with react-pdf, instead of PDFPreviewer, which measures every page before showing any. Every other receipt still uses PDFPreviewer as before. The previous page stays visible until the next one has drawn, so the thumbnail underneath doesn't flash.

The pill shows as soon as pages can be flipped, with its buttons disabled until the PDF loads, so it doesn't change size once it can flip. On devices without hover support, or if the PDF fails to load, the static badge stays instead. Hover zoom pauses while the pointer is over the pill, since tracking the cursor there would hide the page you just flipped to. receipt.pageCount now takes the current page.

Receipts uploaded in the current session are local files, which this layer didn't cover before. With page navigation on, it now does, which adds one extra PDF load for fresh multi-page uploads on desktop.

Known limitation: the PDF is downloaded again each time the receipt is opened, so on large PDFs the arrows take a few seconds to appear. Caching that is a separate out of scope task.

Fixed Issues

$ #102435

Tests

  1. On desktop web, open an expense whose receipt is a multi-page PDF already on the server.
  2. Verify the pill reads "Page 1 of N" with disabled buttons, then both buttons enable once the PDF loads.
  3. Click next and verify the preview shows page 2 and the pill reads "Page 2 of N".
  4. Click previous and verify it goes back to page 1, and that previous is disabled on page 1.
  5. Click next until the last page and verify next is disabled.
  6. Hover the receipt and verify it zooms, then move the pointer onto the pill and verify the zoom stops.
  7. Create a new expense with a multi-page PDF receipt, open it while it's still scanning, and verify the pill appears once the PDF loads and keeps working after the scan finishes.
  8. Open an expense with a single-page PDF or an image receipt and verify no page badge or pill shows.
  9. Block the PDF's network request (or point the receipt at a broken URL) and verify the view falls back to the static "Page 1 of N" badge instead of a stuck or broken pill.
  10. Flip to a later page, then replace the receipt with a different multi-page PDF, and verify the pill resets to page 1 with both buttons disabled until the new file loads.
  • Verify that no errors appear in the JS console

Offline tests

  1. Open an expense with a multi-page PDF receipt that has already loaded, then go offline.
  2. Verify previous/next still flip pages, since the PDF is already loaded.

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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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

Screen.Recording.2026-10-02.at.6.25.47.PM.mov

On desktop the receipt preview already renders the full PDF over the
page 1 thumbnail for hover zoom. The page count badge becomes a pill with
previous/next buttons that scroll that PDF, once it has loaded.
@melvin-bot

melvin-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

PDFPreviewer measures every page before showing any, which took tens of
seconds on long PDFs. Page navigation now renders just the requested page
with react-pdf, so it no longer needs the react-fast-pdf change.
@ishpaul777
ishpaul777 requested a review from huult October 1, 2026 16:23
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 95.90% <ø> (ø)
...rmationListFooter/ConfirmationReceiptThumbnail.tsx 89.65% <ø> (ø)
...nents/ReportActionItem/MoneyRequestReceiptView.tsx 73.33% <100.00%> (+1.27%) ⬆️
...mponents/ReportActionItem/ReceiptPageNavigator.tsx 100.00% <100.00%> (ø)
...ponents/ReportActionItem/ReportActionItemImage.tsx 71.42% <100.00%> (-11.12%) ⬇️
src/libs/TransactionUtils/index.ts 95.23% <100.00%> (+0.02%) ⬆️
src/styles/index.ts 62.96% <100.00%> (+0.17%) ⬆️
src/components/PDFThumbnail/index.tsx 0.00% <0.00%> (ø)
...components/ReceiptHoverZoom/useReceiptHoverZoom.ts 92.30% <33.33%> (-4.92%) ⬇️
...nents/ReportActionItem/ReceiptPDFOverlay/index.tsx 90.19% <84.37%> (+90.19%) ⬆️
... and 9 files with indirect coverage changes

@huult

huult commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

maybe suggest a better approach if any

@ishpaul777 Do we need to wait for the backend or anything else? If not, we can remove the draft status and start working on it. If there are any changes, I’ll update them here as well.

@huult

huult commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-10-02.at.14.34.53.mov
Screenshot 2026-10-02 at 14 36 56 Screenshot 2026-10-02 at 14 37 10

BUG: After the Next and Previous arrows appear, this button becomes larger than before they are displayed.

@huult

huult commented Oct 2, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-10-02.at.14.41.01.mov

Could you check why the page navigation controls are displayed so late? I can see that the PDF has already been uploaded successfully.

Comment thread src/components/ReportActionItem/ReceiptPDFOverlay/index.tsx
Comment thread src/components/ReportActionItem/ReceiptPDFOverlay/index.tsx Outdated
Comment thread src/styles/index.ts Outdated
@huult

huult commented Oct 2, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-10-02.at.15.06.17.mov

BUG: When I click Next or Previous, the navigation controls jump in and out because there isn't enough width.

Comment thread src/components/ReportActionItem/ReceiptPageNavigator.tsx Outdated
@huult

huult commented Oct 2, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-10-02.at.15.10.21.mov

BUG: The tooltip still appears when the button is disabled.

Show the pill as soon as pages can be flipped, with its buttons disabled
until the PDF loads, so it no longer grows when the arrows appear. Reserve
the widest label's width, hide tooltips on disabled buttons, and fall back
to the static badge when the PDF or a page fails to load.
@ishpaul777
ishpaul777 marked this pull request as ready for review October 2, 2026 12:53
@ishpaul777
ishpaul777 requested review from a team as code owners October 2, 2026 12:53
@melvin-bot
melvin-bot Bot requested a review from huult October 2, 2026 12:53
minWidth on the label only set a floor; any count past it still grew the
pill. Per huult's suggestion: the label is now an absolutely positioned
overlay, so it never affects the row's layout. The pill's width comes
only from the two buttons and a fixed spacer between them, so it never
changes size. overflow: hidden masks a label too long to fit.
@ishpaul777

Copy link
Copy Markdown
Contributor Author

@huult can you please give this another review, Thanks!

@huult

huult commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@ishpaul777 Could you check the failing checks?

Comment thread src/components/ReportActionItem/ReceiptPageNavigator.tsx Outdated
@huult

huult commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-10-09 at 13 15 42

BUG: The label gets overlapped or truncated when the text is too long in some languages.

@huult

huult commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-10-09 at 13 17 34

BUG: The focus outline is clipped on both buttons.

Comment thread src/components/ReportActionItem/ReceiptPDFOverlay/index.tsx Outdated
Comment thread src/CONST/index.ts
@ishpaul777

Copy link
Copy Markdown
Contributor Author

@huult Both fixed. The pill now sizes to its longest label ("Page N of N" for the last page), so long translations no longer clip. Removing overflow: hidden also fixes the clipped focus outlines. Please re-check on your side.

@huult huult 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.

Screen.Recording.2026-10-12.at.10.19.02.mov

LGTM.

@melvin-bot

melvin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #102435 as well as to this PR... Please reach out for help on Slack if no one gets assigned!

@melvin-bot
melvin-bot Bot requested a review from flodnv October 12, 2026 03:20
@huult

huult commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot I just approved this. Please update the PR title to include [Payment due @huult].

@MelvinBot MelvinBot changed the title Add page navigation to multi-page PDF receipts [Payment due @huult] Add page navigation to multi-page PDF receipts Oct 12, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor

Done. I updated the PR title to [Payment due @huult] Add page navigation to multi-page PDF receipts.


view run

@ishpaul777

Copy link
Copy Markdown
Contributor Author

@huult you are assigned to this App issue #102435 for payment

@ishpaul777 ishpaul777 changed the title [Payment due @huult] Add page navigation to multi-page PDF receipts Add page navigation to multi-page PDF receipts Oct 12, 2026
@flodnv
flodnv requested a review from MonilBhavsar October 12, 2026 13:57

This branch has not been deployed

No deployments
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.

7 participants