Repository navigation
Description
If you haven't already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: Multiple (not version-specific; observed across 9.4.23–9.4.32)
Reproducible in staging?: Yes
Reproducible in production?: Yes
Email or phone of affected tester (no customers): N/A (production log analysis)
Issue reported by: @mountiny
Related issue: #95824 (share extension Submit tab — separate root cause)
Action Performed:
Pre-requisites:
- iOS device with camera set to High Efficiency (Settings → Camera → Formats → High Efficiency)
- A HEIC photo in the camera roll
- Open the Expensify iOS app.
- Start a new expense with a receipt (Scan flow) or attach a HEIC image via the gallery picker.
- Select a HEIC image from the photo library.
- Submit the expense / upload the attachment.
Note: This failure is intermittent — it occurs when expo-image-manipulator fails to convert the HEIC to JPEG. It is more likely with large images, under memory pressure, or when navigating away during conversion. Production logs show ~235 such conversion failures per week.
Expected Result:
If HEIC→JPEG conversion fails, the user sees a clear error and the upload is blocked. If conversion succeeds, a JPEG is uploaded and the receipt/attachment is accepted.
Actual Result:
When conversion fails, the app logs the error and falls back to the original HEIC file, uploading it anyway. The server rejects it with Unsupported file type: image/heic on UploadReceipt. The expense may be created without a receipt, showing "Receipt upload failed" / "Scanning...".
Production logs (last 7 days):
- ~235
Failed to convert HEIC image, falling back to original(AttachmentPicker) - ~189
HEIC conversion failed, falling back to original file(useFilesValidation) - ~784 total
Unsupported file type: image/heicserver rejections (~185 unique users/week)
Common expo-image-manipulator errors:
Image context has been lost(~215/week)Drawing the new image failed(~7/week)- Android
JobCancellationException(conversion cancelled on navigation)
Workaround:
- Retake the photo with camera set to Most Compatible (JPEG).
- Retry the upload (conversion may succeed on second attempt).
- Use the in-app camera (always produces JPEG).
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome / Safari
Root cause (for implementers)
When convertHeicImage / ImageManipulator.renderAsync() fails, both fallback paths push the original HEIC into the upload queue instead of surfacing an error:
src/hooks/useFilesValidation.tsx(~line 237):onErrorlogsHEIC conversion failed, falling back to original fileand pushesfile(raw HEIC).src/components/AttachmentPicker/index.native.tsx(~line 262):.catchlogsFailed to convert HEIC image, falling back to originaland pushes the original asset.src/libs/fileDownload/heicConverter/index.native.ts(~line 48): logsError converting HEIC/HEIF to JPEGthen delegates to caller'sonError.
The backend PDFs service does not accept image/heic, so every fallback results in a silent receipt-less expense.
Suggested fix
- Stop falling back to raw HEIC — on conversion failure, show a user-facing error (e.g. corrupted/unsupported attachment modal) and block upload.
- Investigate
Image context has been lost— consider retry logic, avoiding parallel conversions, or keeping the app foregrounded during conversion. - Optionally add a final MIME-type guard before upload to reject any remaining
image/heicclient-side.
Screenshots/Videos
Add repro video if available (may require multiple attempts due to intermittent nature).
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022075596975129883002
- Upwork Job ID: 2075596975129883002
- Last Price Increase: 2026-07-10
Issue Owner
Current Issue Owner: @mallenexpensifyMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
MelvinBot commentedon Jul 10, 2026
Proposal
What is the root cause of that problem?
When native HEIC→JPEG conversion fails, both upload paths silently fall back to pushing the raw HEIC file into the upload queue instead of surfacing an error. The backend PDFs service rejects
image/heic(Unsupported file type: image/heiconUploadReceipt), so the expense is created receipt-less / stuck on "Scanning…". Confirmed in code:src/hooks/useFilesValidation.tsx:238-242—convertHeicImage'sonErrorlogsHEIC conversion failed, falling back to original fileand doesconvertedFiles.push(file)(the raw HEIC), which then flows intovalidNonPdfFiles.src/components/AttachmentPicker/index.native.tsx:262-267— theImageManipulator.renderAsync().catchlogsFailed to convert HEIC image, falling back to originaland pushesprocessAssetWithFallbacks(asset), i.e. the original HEIC asset.src/libs/fileDownload/heicConverter/index.native.ts:47-49—renderAsync().saveAsync()failures logError converting HEIC/HEIF to JPEGand delegate to the caller'sonError(which triggers the fallback above).The underlying
expo-image-manipulatorfailures (Image context has been lost,Drawing the new image failed, AndroidJobCancellationExceptionon navigation) are intermittent and increase under memory pressure / with large images — but the user-facing bug is the silent fallback, not the intermittent conversion itself.What changes do you think we should make in order to solve the problem?
Stop falling back to the raw HEIC on conversion failure — surface an error and block the upload instead. The error infrastructure already exists, so this is a targeted change:
useFilesValidation.tsx, in theonErrorhandler, instead ofconvertedFiles.push(file), push a validation error tocollectedErrors.current(e.g.FILE_CORRUPTEDorWRONG_FILE_TYPE— both already defined inCONST.FILE_VALIDATION_ERRORSwith user-facing text wired throughgetFileValidationErrorText). This shows the existing corrupted/unsupported-attachment modal and blocks the bad upload.AttachmentPicker/index.native.tsx, replace the raw-asset fallback in the.catchwith a user-facing error (this path already hasshowGeneralAlertavailable in the sibling catch at L275-278).image/heicclient-side as defense-in-depth.Separately (lower priority, does not block the fix above), investigate reducing the
Image context has been lostfailures — e.g. avoiding parallel conversions and keeping the app foregrounded during conversion — to reduce how often users hit the error at all.What alternative solutions did you explore? (Optional)
renderAsync()a second time (and/or serialize conversions instead ofPromise.all) before surfacing an error. Reduces the failure rate but doesn't remove the need for the error path in step 1.Related issues (same HEIC root theme, separate root causes)
Unsupported file type: image/heic.These are distinct code paths but share the theme of unconverted HEIC reaching the backend. Worth coordinating fixes, but this issue is scoped to the iOS/Android in-app pick/scan fallback.
Confidence & verification notes
Confidence: High on the code root cause — all three fallback sites verified at the exact file:line references above against
846ccd5, and the required error constants/text handling already exist. The production log frequencies (~235/wk AttachmentPicker fallbacks, ~189/wk useFilesValidation fallbacks, ~784/wk server rejections, ~185 unique users/wk) are as reported in the issue body and were not independently re-queried here; they are consistent with the confirmed silent-fallback behavior.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/95825)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
aswin-s commentedon Jul 10, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS and Android, when a user selects a HEIC image from the gallery and
expo-image-manipulatorfails to convert it to JPEG, the app silently falls back to uploading the original HEIC file. The backend rejects it withUnsupported file type: image/heic, resulting in a receipt-less expense and a "Receipt upload failed"/"Scanning..." state. Expected behavior is that a conversion failure surfaces a user-visible error (corrupted/unsupported attachment modal) and blocks the upload.What is the root cause of that problem?
Both HEIC conversion consumers swallow the failure and enqueue the raw HEIC as a substitute for the JPEG the server requires. In src/hooks/useFilesValidation.tsx:239, the
onErrorcallback logsHEIC conversion failed, falling back to original fileand thenconvertedFiles.push(file)(line 240) queues the original HEIC. In src/components/AttachmentPicker/index.native.tsx:263, the.catchblock logsFailed to convert HEIC image, falling back to originaland pushesprocessAssetWithFallbacks(asset)(line 264-265) — which is still the unconverted HEIC asset. BecauseconvertHeicImage(src/libs/fileDownload/heicConverter/index.native.ts:61) only reports the error viaonErrorand does not itself block the caller, the wrong-branch decision to keep pushing the HEIC on failure lives entirely in these two consumer callbacks, and the resultingimage/heicpayload is rejected byUploadReceipt.What changes do you think we should make in order to solve the problem?
src/hooks/useFilesValidation.tsx(~line 238-242): in theconvertHeicImageonErrorcallback, do NOTconvertedFiles.push(file). Instead, route the file through the existing invalid/unsupported-attachment error path used byuseFilesValidation(the sameErrorModalsurface exposed by the hook) so the user sees the "corrupted/unsupported attachment modal" and the upload is blocked. Resolve the promise without appending, and mark the batch as having a validation error so the caller does not proceed with a partial upload.src/components/AttachmentPicker/index.native.tsx(~line 262-267): in the.catchbranch, stop callingprocessAssetWithFallbacks(asset)/ pushing the original HEIC. Surface the failure to the picker's error UI (the same modal used for other unsupported attachments) and drop the asset fromprocessedAssets, thencheckAllProcessed()so the batch completes without the invalid file.src/libs/fileDownload/heicConverter/index.native.ts(~line 48-61): keep the currentonErrorcontract but ensure the error object/message is propagated to callers so both consumers can render a specific "HEIC conversion failed" message rather than a generic error.image/heicorimage/heifclient-side with the same unsupported-attachment modal, so any future fallback path cannot leak a HEIC toUploadReceipt.useFilesValidationandAttachmentPicker/index.nativethat simulates aconvertHeicImagefailure and asserts (a) the file is NOT pushed to the upload queue and (b) the error modal state is set.What alternative solutions did you explore? (Optional)
Retrying conversion once on
Image context has been lostbefore surfacing the error could recover some intermittent failures, but should be layered on top of the block-on-failure fix, not instead of it.melvin-bot commentedon Jul 10, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (
External)samranahm commentedon Jul 10, 2026
Proposal
What is the root cause of that problem?
When a user attempts to upload a HEIC image as a receipt or attachment, the application tries to convert it to JPEG using
expo-image-manipulator. If this conversion fails, the app currently has fallback logic that pushes the original, unconverted HEIC file into the upload queue instead of blocking the upload or showing an error.Specifically, this occurs in two main locations:
useFilesValidation.tsx, whenconvertHeicImagefails, theonErrorcallback logs "HEIC conversion failed, falling back to original file" and proceeds to return the originalfileobject:App/src/hooks/useFilesValidation.tsx
Line 237 in 846ccd5
AttachmentPicker/index.native.tsx, the.catchblock for the conversion process logs "Failed to convert HEIC image, falling back to original" and then pushes the original asset for upload:App/src/components/AttachmentPicker/index.native.tsx
Line 262 in 846ccd5
The backend PDF service does not support
image/heicfiles, leading to server rejections with "Unsupported file type: image/heic". This results in a "Receipt upload failed" message for the user, and the expense is created without a receipt, despite the client-side logging the conversion failure.What changes do you think we should make in order to solve the problem?
The core problem is the fallback to the original HEIC file on conversion failure. We should prevent this fallback and instead surface a user-facing error.
Modify
useFilesValidation.tsxto prevent falling back to the original HEIC file whenconvertHeicImagefails. Instead of returning the originalfile, it should indicate an error, preventing the file from being processed for upload.App/src/hooks/useFilesValidation.tsx
Line 237 in 846ccd5
Update
AttachmentPicker/index.native.tsxto handle conversion failures by blocking the upload and showing a user-facing error. The.catchblock should not push the original asset.App/src/components/AttachmentPicker/index.native.tsx
Line 262 in 846ccd5
Introduce a client-side MIME-type validation check in
FileUtils.tswithin thevalidateReceiptfunction, or a similar pre-upload validation, to explicitly rejectimage/heicfiles before they are sent to the server. This acts as a final safeguard.App/src/libs/fileDownload/FileUtils.ts
Lines 681 to 682 in 846ccd5
These changes will ensure that if HEIC conversion fails, the user is informed, and the unsupported file is not uploaded, preventing the "Receipt upload failed" scenario.
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
[-]iOS/Android - HEIC conversion failure falls back to raw HEIC upload, causing receipt upload failure[/-][+][$250] iOS/Android - HEIC conversion failure falls back to raw HEIC upload, causing receipt upload failure[/+]melvin-bot commentedon Jul 10, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022075596975129883002
yusufdeveloper2903 commentedon Jul 10, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When native HEIC→JPEG conversion fails, the app uploads the original
image/heicfile instead of surfacing an error, soUploadReceiptrejects it withUnsupported file type: image/heicand the expense ends up receipt-less.What is the root cause of that problem?
The converter itself is correct — on failure it does the right thing and delegates to the caller's
onErrorinstead of pretending it succeeded, atheicConverter/index.native.ts:47-49:The bug is entirely in the two native callers, which treat that
onErroras "upload the original anyway" rather than "block and warn". Both re-enqueue the raw HEIC into the upload set.Caller 1 —
useFilesValidation(gallery / drag-drop / multi-file scan): theonErrorhandler logs and pushes the untouchedfileintoconvertedFiles, which is then merged intovalidNonPdfFilesand handed toonFilesValidatedfor upload:App/src/hooks/useFilesValidation.tsx
Lines 238 to 242 in 1d5d806
That
convertedFilesarray is what gets uploaded — see the merge atuseFilesValidation.tsx:249and theonFilesValidated(...)dispatch atuseFilesValidation.tsx:298-299. So a failed conversion silently becomes a "valid" HEIC upload.Caller 2 —
AttachmentPicker/index.native.tsx(camera roll / Scan flow): the inner.catchonrenderAsync().saveAsync()falls back toprocessAssetWithFallbacks(asset), which returns the original HEIC asset and pushes it toprocessedAssets:App/src/components/AttachmentPicker/index.native.tsx
Lines 262 to 267 in 1d5d806
This is a control-flow bug, not a data-layer one — the file is genuinely unconvertible; the handlers just mis-route a failure into the success queue. It is also inconsistent with the correct pattern that already sits right next to it: the outer
verifyFileFormat(...).catchin the very same block already does the right thing — it callsshowGeneralAlert(...)and does not enqueue the asset, atAttachmentPicker/index.native.tsx:275-278. AnduseFilesValidationalready has the exact "surface it as a corrupted-file error" precedent it needs for its resize failures, atuseFilesValidation.tsx:271.Why it only fires intermittently, and only on native:
ImageManipulator.renderAsync()normally succeeds and a JPEG is uploaded, so the fallback branch is never hit — it only fires when the manipulator rejects (Image context has been lost,Drawing the new image failed, AndroidJobCancellationExceptionon navigation), which matches the reported "intermittent, worse under memory pressure / when navigating away" behavior. The web converter atheicConverter/index.ts:87-89already callsonErrorwithout an original-file fallback, which is exactly why this is an iOS/Android-only bug.What changes do you think we should make in order to solve the problem?
Stop routing a conversion failure into the upload queue in both native callers; reuse the error UI each caller already has. The
image/heicMIME never reaches the server, so the receipt-less expense can't happen.1.
src/hooks/useFilesValidation.tsx— in theconvertHeicImageonError, push aFILE_CORRUPTEDerror instead of the raw file, mirroring the existing resize-failure handling at line 271:onError: () => { Log.warn('HEIC conversion failed, falling back to original file', {fileName: file.name}); - convertedFiles.push(file); + collectedErrors.current.push({error: CONST.FILE_VALIDATION_ERRORS.FILE_CORRUPTED, isValidatingMultipleFiles: validationState.isValidatingMultipleFiles}); resolve(); },This surfaces the existing corrupted-attachment modal —
getFileValidationErrorTextalready mapsFILE_CORRUPTEDtoattachmentPicker.attachmentError/errorWhileSelectingCorruptedAttachmentatFileUtils.ts:823-827— with no new copy needed.2.
src/components/AttachmentPicker/index.native.tsx— in the inner conversion.catch, replace the raw-asset fallback withshowGeneralAlert(...)and skip the asset, exactly like the siblingverifyFileFormat.catchtwo lines below already does:.catch((error: Error) => { Log.warn('Failed to convert HEIC image, falling back to original', {error: error.message}); - const fallbackAsset = processAssetWithFallbacks(asset); - processedAssets.push(fallbackAsset); checkAllProcessed(); });Call
showGeneralAlert(translate('attachmentPicker.errorWhileSelectingCorruptedAttachment'))beforecheckAllProcessed()so the user gets a clear message instead of a silent failure.This is safe because:
onSuccess/ the JPEG.then) are untouched, so every currently-working conversion behaves identically.FILE_CORRUPTEDalready has full modal + copy support ingetFileValidationErrorText, and it's the same code the resize-failure path uses, so no new translation keys or components are introduced.AttachmentPickerchange adopts the exact error-surfacing pattern already used by the adjacentverifyFileFormatcatch in the same function, so behavior stays consistent within the file.Note: the
Image context has been losterrors (~215/week) are a separate reliability concern — worth a follow-up to retry once and/or serialize conversions (the current multi-file path fires them in parallel viaPromise.allatuseFilesValidation.tsx:214, which increases memory pressure). That reduces how often we hit the error, but it does not substitute for this fix — any residual failure must still block the upload rather than send raw HEIC.Optionally we can add a final MIME guard right before
UploadReceipt/attachment upload that rejects any file whose type is stillimage/heic/image/heif, as belt-and-suspenders for any future caller that regresses.Result: a failed HEIC conversion now shows the user the corrupted-attachment error and blocks the upload on both native entry points, so
UploadReceiptnever receivesimage/heicand no receipt-less expense is created.What alternative solutions did you explore? (Optional)
useFilesValidation(the RCA the issue body emphasizes) — rejected as incomplete: production logs show ~235/week failures fromAttachmentPickervs ~189 fromuseFilesValidation, so a fix that skips the camera-roll/Scan path inAttachmentPicker/index.native.tsxleaves the majority of the failures in place.KJ21-ENG commentedon Jul 10, 2026
Proposal
What is the root cause of that problem?
Native HEIC conversion failures are handled as successful selections. In the generic receipt/attachment validation path,
convertHeicImage()correctly callsonErrorwhenImageManipulatorfails, butuseFilesValidationlogs that error and pushes the original.heic/.heiffile intoconvertedFiles, which is later appended to the valid upload list.App/src/hooks/useFilesValidation.tsx
Lines 218 to 249 in 846ccd5
The native gallery picker has the same fallback pattern in its inline HEIC signature conversion: when
renderAsync()/saveAsync()rejects, it logs the failure, wraps the original asset with fallback metadata, and adds it toprocessedAssets, so the downstream upload still receives the raw HEIC file.App/src/components/AttachmentPicker/index.native.tsx
Lines 239 to 267 in 846ccd5
The shared native converter is not the layer creating the bad upload candidate: it reports conversion failure through
onErrorand leaves the caller to decide what to do.App/src/libs/fileDownload/heicConverter/index.native.ts
Lines 32 to 53 in 846ccd5
Because native uploadability only requires a
uri, a raw HEIC object that survives validation can still be sent in the request payload with its original type/name instead of being blocked client-side.App/src/libs/isFileUploadable/index.native.ts
Lines 3 to 8 in 846ccd5
App/src/libs/prepareRequestPayload/index.native.ts
Lines 24 to 39 in 846ccd5
What changes do you think we should make in order to solve the problem?
In
useFilesValidation, change theconvertHeicImageonErrorhandler so it does not push the original file intoconvertedFiles. Instead, add aFILE_CORRUPTEDvalidation error for that file, resolve the conversion promise, and let the existing error modal block single-file receipt upload or continue with only other valid files in multi-file selection. This reuses the existing corrupted-attachment copy and modal plumbing.App/src/libs/fileDownload/FileUtils.ts
Lines 823 to 827 in 846ccd5
In
AttachmentPicker/index.native.tsx, change the HEIC conversion.catchso it shows the same attachment error and does not addprocessAssetWithFallbacks(asset)toprocessedAssets. AftercheckAllProcessed(), the existingprocessedAssets.length > 0 ? processedAssets : undefined/onCanceledbehavior will prevent the failed single asset from reachingpickAttachment, while preserving any other successfully processed assets in multi-select.App/src/components/AttachmentPicker/index.native.tsx
Lines 226 to 287 in 846ccd5
App/src/components/AttachmentPicker/index.native.tsx
Lines 370 to 391 in 846ccd5
As a defense-in-depth follow-up inside this same fix, add a small client-side guard before receipt upload/validation completion that rejects any remaining
.heic/.heiforimage/heic/image/heifreceipt object instead of relying on the backend rejection. That guard should surface the same attachment error and not silently omit a receipt after the user submits.Test coverage:
useFilesValidationwith a mockedconvertHeicImagefailure proving a HEIC receipt is not passed toonFilesValidatedandFILE_CORRUPTEDis surfaced.AttachmentPickerHEIC conversion catch path with a mockedImageManipulatorrejection, proving the raw asset is not passed tocompleteAttachmentSelectionand the attachment error is shown.image/heicreceipt cannot be submitted even if a platform picker supplies misleading metadata.What alternative solutions did you explore? (Optional)
I considered changing
convertHeicImageitself to automatically return an error file or throw, but its current callback contract is correct: it detects the conversion failure and reports it viaonError; the bad behavior is introduced by callers that intentionally convert that error back into a valid raw HEIC upload. I also considered adding only an upload-layer MIME guard, but that would catch the backend failure late and could still allow confusing optimistic receipt state. Blocking at the two selection/validation fallbacks gives the user immediate feedback, while the upload guard remains useful defense-in-depth.github-actions commentedon Jul 10, 2026
trasnake87 commentedon Jul 10, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
46 remaining items
mallenexpensify commentedon Aug 20, 2026
Payment Summary
Contributor: @annaweber830 paid $250 via Upwork
Contributor+: @FitseTLT due $250 via NewDot
@annaweber830 can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
https://www.upwork.com/jobs/~022090564489671038585
annaweber830 commentedon Aug 25, 2026
Thanks, @mallenexpensify. I've accepted the offer.
mallenexpensify commentedon Aug 26, 2026
@annaweber830 paid, summary updated above. Thx.
flaviadefaria commentedon Sep 2, 2026
Approved: @FitseTLT due $250 via NewDot