Fix PDF receipts not loading when receipt.source is missing#81960
Conversation
…ssing When receipts are added via email or billing, the backend sometimes provides receipt.filename without receipt.source. This causes the receipt viewer to receive a blank URL, leaving PDF previews empty. Apply the same fallback used in MergeTransactionUtils directly in getThumbnailAndImageURIs so all receipt display paths benefit: construct the URL as https://www.expensify.com/receipts/{filename} when source is missing but filename exists. Co-authored-by: Jan Nowakowski <jnowakow@users.noreply.github.com>
|
@mananjadhav 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c460bc9da
ℹ️ 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".
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.
|
|
I tried testing this in different ways - preloaded attachment, not opened attachment, etc. But it always ends up not loading the PDF preview. web-pdf-receipts-no-preview.mov |
|
@mananjadhav I think it's because you are using network tab to go offline instead of our debug tools (cmd + d). If you disable internet through network tab PDF cannot be downloaded so it displays default view. Our debug tools probably disable just API calls instead of completely blocking Internet allowing the pdf to be downloaded. Can you retest it? |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safariweb-pdf-source.mov |
mananjadhav
left a comment
There was a problem hiding this comment.
Because this needs manual update of Onyx store, I am uploading a screenshot of Web only.
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #78846 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
Quick bump @AndrewGable |
|
@mananjadhav I think @AndrewGable is OOO this week |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @AndrewGable has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/AndrewGable in version: 9.3.32-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.32-3 🚀
|
Explanation of Change
This is copy of Melvin's PR with additional commit that extracts receipts URL to config. Below is Melivn's description.
When receipts are added via email forwarding or Expensify billing, the backend sometimes provides receipt.filename without populating receipt.source. The getThumbnailAndImageURIs function in ReceiptUtils.ts returns an empty string for the image path when source is missing, causing the PDF viewer to receive a blank URL and display nothing.
This fix adds a fallback in getThumbnailAndImageURIs: when receipt.source is missing but receipt.filename exists, construct the URL as https://www.expensify.com/receipts/{filename}. This is the same workaround already used in MergeTransactionUtils.ts:fillMissingReceiptSource, but applied at the general receipt utility level so all receipt display paths (not just merge) benefit from it.
Fixed Issues
$ #78846
PROPOSAL: N/A
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
receipts-web.mov