Skip to content

Show receipt page count badge for split expenses - #100361

Merged
MonilBhavsar merged 11 commits into
Expensify:mainfrom
ishpaul777:ishpaul/split-expense-receipt-page-count
Sep 21, 2026
Merged

MonilBhavsar merged 11 commits into
Expensify:mainfrom
ishpaul777:ishpaul/split-expense-receipt-page-count

Conversation

@ishpaul777

@ishpaul777 ishpaul777 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Show a page count badge on multi-page PDF receipts never showed the badge for split expenses. ConfirmationReceiptThumbnail, used by the split confirmation screen, had no badge logic at all. buildOptimisticTransaction also dropped receipt.pageCount when building each split's child transaction. Both fixed here.

The badge still won't render for a new split until the linked Auth and Web-Expensify PRs land too — the page count doesn't currently survive StartSplitBill/CompleteSplitBill on the backend.

Fixed Issues

$ #100350
PROPOSAL:

Backend counterparts, need to land together:

Tests

  1. Create a split scan expense using a multi-page PDF receipt.
  2. Verify the badge shows on the split confirmation screen thumbnail.
  3. Complete the split. Open one of the resulting individual expenses.
  4. Verify the badge still shows there with the correct page count.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests — creating and completing a split expense works the same offline, syncing once back online.

QA Steps

  1. Create a split scan expense with a multi-page PDF receipt.
  2. Confirm the badge appears on the split confirmation screen and on each resulting expense.
  • 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

Screen.Recording.2026-09-13.at.7.24.45.PM.mov

buildOptimisticTransaction rebuilt the receipt from a fixed field list
that omitted pageCount, so a multi-page receipt scanned into a split
expense lost its page count on the child transactions the split creates.
ConfirmationReceiptThumbnail (used by the split expense confirmation
flow) never had the page count badge added, so multi-page PDF receipts
scanned into a split expense showed no page count at all.
isPDF can be boolean | undefined since isLocalFile is optional, so
shouldShowReceiptPageCount needs a boolean coercion before use in JSX.
The badge only rendered inside the PDFThumbnail branch, which requires
isLocalFile (a blob/file:// path). Once a receipt is uploaded its
source is a remote URL, so the split-details screen took the
ReceiptImage branch instead and never showed the badge. Decouple the
badge from isLocalFile and render it as a sibling of both branches.
@ishpaul777
ishpaul777 marked this pull request as ready for review September 13, 2026 13:56
@ishpaul777
ishpaul777 requested review from a team as code owners September 13, 2026 13:56
@melvin-bot
melvin-bot Bot requested review from MonilBhavsar and heyjennahay and removed request for a team and heyjennahay September 13, 2026 13:56
@melvin-bot

melvin-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

@MonilBhavsar 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 commented Sep 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T14:07:30.711565Z 0a57b4f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@trjExpensify

Copy link
Copy Markdown
Contributor

@abzokhattab what's your ETA to review?

@abzokhattab

Copy link
Copy Markdown
Contributor

i missed this one. Thanks for the reminder

@abzokhattab

Copy link
Copy Markdown
Contributor

we have conflicts @ishpaul777

@ishpaul777

Copy link
Copy Markdown
Contributor Author

fixed conflicts and merged main

@abzokhattab

Copy link
Copy Markdown
Contributor

reviewing now ... btw we have failing eslint checks @ishpaul777

@abzokhattab

abzokhattab commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Found this bug:

  1. Submit a split expense with a multi-page receipt.
  2. Open DevTools → Application → Clear site data.
  3. In DevTools → Network, set throttling to Slow 3G.
  4. Open the expense.

Expected result: the page count badge should not appear until the receipt has finished loading.

Actual result: the badge appears immediately along with the loading indicator.

Screen.Recording.2026-09-18.at.00.20.21.mov

@ishpaul777

ishpaul777 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@abzokhattab fixed the bug and fixed lint failing

@abzokhattab

Copy link
Copy Markdown
Contributor

@codex @MelvinBot re-review

@MelvinBot

MelvinBot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Re-review of c641f31. The page-count plumbing is correct, but the ImageWithLoading change has a regression risk that was previously documented in that exact spot.

1. Removing the preview onLoad can leave the receipt view stuck loading (blocker-ish)

src/components/ImageWithLoading.tsx:90-102 — the only live consumer that passes previewUri and an onLoad is MoneyRequestReceiptView.tsx:707, where onLoad is the only thing that clears isLoading. That flag gates far more than the badge: zoom, expand, hover actions, the borderless loading style, and the receipt audit/violation messages in WideRHP (:547, :551, :554, :792).

That code used to carry a comment saying this is unsafe, removed by Fix receipt full-res image not loading when preview displaces it in flow, which kept the preview onLoad:

The full-resolution image is not guaranteed to ever emit onLoad/onError (e.g. a receipt derivative that is still being generated server-side), so isLoading can stay true indefinitely.

The onError path is still covered (handleError → onLoadFailure → setIsLoading(false)), so this only bites the silent case — full-res image emits neither event. If that case is real, the result is a permanently dimmed receipt behind a spinner with violations hidden. Suggest keeping the badge gate but giving the parent a way out: a separate onPreviewLoad prop, or a timeout fallback in MoneyRequestReceiptView. Worth a word with neerajbachani, who authored that PR, before merging.

2. Two badge sites now disagree on load failure

MoneyRequestReceiptView shows the badge on onLoadFailure (:708) — i.e. over the fallback Gallery/offline icon. The new site passes no onLoadFailure, so the badge stays hidden forever once ThumbnailImage.tsx:122-137 takes its sticky failedToLoad early return. Hiding is the better behaviour — but pick one and make both match.

3. isReceiptLoaded isn't re-armed on receipt change

ConfirmationReceiptThumbnail.tsx:127-129 only resets when isLoadingReceipt flips. Swap the receipt without stitching and the stale true puts the badge straight back over a still-loading image. The sibling re-arms on receipt-source change (:228-233) — mirror that.

4. The headline change has no test

The new test covers MoneyRequestReceiptView only. There is no test anywhere for the ConfirmationReceiptThumbnail badge — neither "shows for a multi-page PDF" nor "hidden while loading" — which is the component this PR exists to fix.

Verified as correct — no action needed
  • pageCount plumbing. pageCount?: number | null on the Receipt type (Transaction.ts:285). TransactionUtils/index.ts:593-601 was the only whitelist dropping it; every other split path spreads the receipt (Split.ts:1108-1128) or deep-merges, and the selector copies the whole receipt object. Fix is in the right place.
  • Remote PDFs do reach onLoad. ReceiptUtils only sets isThumbnail for non-image/non-PDF files and pending-waypoint distance requests (ReceiptUtils.ts:87-98), so a remote PDF takes the ThumbnailImage branch, which wires onLoad down to expo-image. The dead-onLoad branches (EReceiptThumbnail, EReceiptStaticThumbnail) are unreachable when Str.isPDF(receiptFilename) holds.
  • setIsReceiptLoaded(false) during render is the sanctioned derived-state pattern and terminates — the condition is false after the re-render.
  • All CI checks pass except Check independent approval.

I couldn't exercise this in a live session — the web test session died before it could reach the app — so point 1 needs a manual check: open an expense whose full-res receipt derivative isn't ready yet and confirm the receipt still settles.


view run · no recording available

@trjExpensify

Copy link
Copy Markdown
Contributor

@abzokhattab can you complete your review, today?

@abzokhattab

Copy link
Copy Markdown
Contributor

@trjExpensify Was already looking at it ... I already reviewed once and sent back a loading-badge bug .. and there are few points from melvin ... posting the checklist soon

@abzokhattab

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 Screenshot 2026-09-21 at 13 44 01
Android: mWeb Chrome Screenshot 2026-09-21 at 13 47 28
iOS: HybridApp Screenshot 2026-09-21 at 13 35 52
Screen.Recording.2026-09-21.at.13.31.57.mov
iOS: mWeb Safari Screenshot 2026-09-21 at 13 33 41
MacOS: Chrome / Safari
Screen.Recording.2026-09-21.at.13.26.55.mov

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

i verified the melvin suggested changes but they look incorrect ... only the 4th point regarding the tests is correct its also NAB

also the mentioned bug is now fixed

Screen.Recording.2026-09-21.at.13.25.57.mov

so approving.

@MonilBhavsar
MonilBhavsar merged commit 49c7684 into Expensify:main Sep 21, 2026
35 of 37 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.4.91-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR, so I did not create a draft PR.

Why: this PR fixes a bug in an existing visual affordance — the Page 1 of N badge on multi-page PDF receipt thumbnails — so it shows on the split confirmation screen and on the resulting split expenses. It adds no new user-facing workflow, setting, button, or label.

What I checked

The change itself — all five changed files are component, util, and test code:

No copy was added or changed. The badge string already exists as receipt.pageCount → Page 1 of ${pageCount} and was introduced by Show a page count badge on multi-page PDF receipts.

The help site — I searched docs/articles for page count, multi-page, multipage, and PDF:

  • No New Expensify article mentions the page count badge or multi-page PDF receipts. The only hit is a Classic article about emailing multi-page receipts to receipts@expensify.com, which this PR does not affect.
  • Attach and edit receipts on expenses documents attaching, replacing, cropping, and rotating receipts — none of that behavior changes here.
  • Split Expenses documents splitting one expense into multiple rows — a different flow from the split confirmation screen this PR touches.

So no existing article is now inaccurate, and the earlier PR that introduced the badge did not ship docs either.

One more reason to hold off: per your PR description, the badge will not render for a new split until the linked backend PRs land, because the page count does not yet survive the split creation round trip. Documenting the badge before that would describe behavior users can't see yet.

If you'd still like it documented, the natural home is a short FAQ entry under Attach and edit receipts on expenses — something like "Why does my PDF receipt show a Page 1 of N badge?" Reply with @MelvinBot create the docs PR once the backend PRs are live and I'll open it.

Since no help site PR was created, there is nothing to mark Ready for review.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.91-3 🚀

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

Bundle Size Analysis (Sentry):

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.

6 participants