Skip to content

fix: Can't upload a receipt in HEIC format, page reloads or loads infinitely#69634

Closed
martasudol wants to merge 5 commits into
Expensify:mainfrom
callstack-internal:fix/heic-image-upload
Closed

fix: Can't upload a receipt in HEIC format, page reloads or loads infinitely#69634
martasudol wants to merge 5 commits into
Expensify:mainfrom
callstack-internal:fix/heic-image-upload

Conversation

@martasudol

@martasudol martasudol commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Explanation of Change

The main fix was removing the blocking error and instead implementing a pass-through fallback. When HEIC conversion fails (whether due to the heic-to library not recognizing the file or any other reason), instead of preventing the upload entirely.

Fixed Issues

$#68778

Tests

  1. Navigate to the workspace chat, tap +, "Create expense"
  2. Tap "Choose file", select a receipt in the HEIC format
  3. Scan expense is created successfully
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests.

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
    • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • 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 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-native.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov

@martasudol martasudol marked this pull request as ready for review September 2, 2025 09:36
@martasudol martasudol requested review from a team as code owners September 2, 2025 09:36
@melvin-bot melvin-bot Bot requested review from QichenZhu and removed request for a team September 2, 2025 09:36
@melvin-bot

melvin-bot Bot commented Sep 2, 2025

Copy link
Copy Markdown

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

@QichenZhu

Copy link
Copy Markdown
Contributor

Hi @martasudol, it seems the server doesn't support HEIC format yet, so the receipt upload will fail if we passthrough the file.

Screen recording

RPReplay_Final1756809870.mp4

Server response

Screenshot 2025-09-02 at 10 45 21 PM

Console warnings

Screenshot 2025-09-02 at 10 46 08 PM

@martasudol

Copy link
Copy Markdown
Contributor Author

@QichenZhu could you share with me the test file that you use?

@QichenZhu

Copy link
Copy Markdown
Contributor

Sure! Here it is: #68778 (comment)

@mountiny

mountiny commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Yeah HEIC is not supported by the server, it has to be converted before being posted I believe cc @Beamanator

@Beamanator

Copy link
Copy Markdown
Contributor

This is def consistent with #47078 (comment), but I don't quite remember "why" - if there was a limitation on our backend or if we just wanted the img to optimistically upload & have a preview

@martasudol

Copy link
Copy Markdown
Contributor Author

@QichenZhu I've jus tested it with your file and it works:
web:

Nagranie.z.ekranu.2025-09-3.o.08.55.25.mov

ios native:

Nagranie.z.ekranu.2025-09-3.o.08.57.47.mov

@QichenZhu

Copy link
Copy Markdown
Contributor

@martasudol, could you try it on a physical device? I'm using iPad Pro 10.5, iOS 17.7.9.

@QichenZhu

Copy link
Copy Markdown
Contributor

Steps:

  1. Download the photo from https://drive.google.com/file/d/1pi5if4sy6Ax0p4AtmkPxo_RmtZUhkxOG/view?usp=sharing and save it into "Files"
  2. Tap FAB - Create expense - Scan
  3. Tap "Choose Files", select the file in step 1
  4. Try to submit the expense

Expected result: The expense is created and the receipt is scanned
Actual result: The page keeps loading, crashes, or shows "There was an error uploading your receipt"

@github-actions

github-actions Bot commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
Built from App PR #69634.

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/69634/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/69634/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/69634/NewExpensify.dmg https://69634.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@IuliiaHerets

Copy link
Copy Markdown

QA team tested these steps with iOS adhoc build. No loading errors or crashes. Receipt got uploaded, but got a scanning error stating details need to be entered manually. Same behaviour for two testers with iPhone 16/iOS 18.3.1 and iPhone 16 Pro Max/18.6

ScreenRecording_09-04-2025.08-44-29_1.mp4
ScreenRecording_09-04-2025.08-26-07_1.MP4

@QichenZhu

Copy link
Copy Markdown
Contributor

Thanks @IuliiaHerets! Good to know the HybridApp is working. How about mWeb Safari?

@IuliiaHerets

Copy link
Copy Markdown

@QichenZhu Do you want to test us on the staging build on Safari?

@IuliiaHerets

Copy link
Copy Markdown

@QichenZhu @mountiny

  1. iPhone 15 iOS 18.5 Safari, mentioned receipt failed the scan, another HEIC receipt - page reloaded, receipt is not uploaded. Same result as in the issue
    https://github.com/user-attachments/assets/b59da980-b5a3-4a09-8bb7-23ec7ab07d2b

  2. iPhone 16/18.3.1/Safari- receipt uploaded but scanning failed to enter details manually
    https://github.com/user-attachments/assets/c7cdfb74-2245-49c4-b708-ff87de74c46d

@QichenZhu

QichenZhu commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

Thank you! That's really helpful.

Summary

Test results with this PR on mWeb Safari following these steps.

Device type Model iOS version RAM (GB) Issue reproducible?
Physical iPhone 13 17.3 4 Yes
Simulator iPhone 15 Pro Max 17.5 N/A Yes
Physical iPad Pro 10.5 17.7.9 4 Yes
Physical iPhone 15 Plus 18.0 6 No
Physical iPhone 16 18.0 8 No
Physical iPhone 16 18.3.1 8 No
Physical iPhone 13 mini 18.4.1 4 Yes
Physical iPhone 15 18.5 6 Yes

@martasudol

Copy link
Copy Markdown
Contributor Author

Thanks @QichenZhu @IuliiaHerets for testing! So it looks like the main problem now is scanning, not uploading. Probably after failed scanning, uploading is blocked. Let me look into this.

@QichenZhu

QichenZhu commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

So it looks like the main problem now is scanning

@martasudol, I don't think that's the main problem here.

The original issue is about the upload failure in No. 1 of the comment:

page reloaded, receipt is not uploaded. Same result as in the issue

The scan failure in No. 2 is a separate issue:

receipt uploaded but scanning failed to enter details manually

@martasudol

Copy link
Copy Markdown
Contributor Author
  1. https://github.com/user-attachments/assets/b59da980-b5a3-4a09-8bb7-23ec7ab07d2b

Yes but note that in this recording the flow is the following:

  1. upload HEIC file - works
  2. scanning first file - failed
  3. upload second HEIC file - failed

@QichenZhu

Copy link
Copy Markdown
Contributor

@martasudol, good point! I just tested this: the page could also crash if you upload the file without submitting it for scan, go back and upload the same file again. Repeat it 4-5 times if it doesn't crash.

Screen.Recording.2025-09-08.at.9.58.12.PM.mov

@martasudol

martasudol commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

Ok, I see a few problems here. Please take a look at the recording below – it’s from staging, where I tried to upload and scan a JPEG file.

  1. On the first attempt, the file didn’t upload at all.
  2. On the second attempt, I got the error: "There was an error uploading your receipt."
  3. When clicking on the newly created expense, I see the "Hmm... it's not here" page.
Nagranie.z.ekranu.2025-09-9.o.09.45.15.mov

For HEIC files on staging, it behaves as we’ve already described.

Something is definitely off here. It looks like failed scanning is common for both JPEG and HEIC (so it’s not really related to the file format).

I’d recommend splitting uploading (as you can note in the above recording, it also didn't work on first attempt for JPEG) and scanning into two separate issues.

cc @gedu as I know you're working on another issue with scanning process.

@mountiny

mountiny commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

@martasudol that is definitely off, I have not seen this issue in staging before, that seems like a bug / deploy blocker

@gedu

gedu commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Yeah, mine is different behaviour, it's related with SequentialQueue and killing the app

@martasudol

Copy link
Copy Markdown
Contributor Author

@martasudol that is definitely off, I have not seen this issue in staging before, that seems like a bug / deploy blocker

100% agree. I’ll be out of office from tomorrow until next Monday, but someone from the Callstack team will take it over in the meantime. cc @mountiny @gedu

@m-natarajan

Copy link
Copy Markdown

Unable to reproduce this in staging and production by uploading jpeg file, but at times have to select file twice to upload

bandicam.2025-09-09.18-17-59-502.mp4
bandicam.2025-09-09.17-37-32-325.mp4

@mountiny

mountiny commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

I believe we can close this one now, thank you!

@mountiny mountiny closed this Oct 3, 2025
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