Skip to content

[Due for payment 2026-08-19] [$250] iOS/Android - HEIC conversion failure falls back to raw HEIC upload, causing receipt upload failure #95825

Closed

Description

@mountiny

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
  1. Open the Expensify iOS app.
  2. Start a new expense with a receipt (Scan flow) or attach a HEIC image via the gallery picker.
  3. Select a HEIC image from the photo library.
  4. 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/heic server 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): onError logs HEIC conversion failed, falling back to original file and pushes file (raw HEIC).
  • src/components/AttachmentPicker/index.native.tsx (~line 262): .catch logs Failed to convert HEIC image, falling back to original and pushes the original asset.
  • src/libs/fileDownload/heicConverter/index.native.ts (~line 48): logs Error converting HEIC/HEIF to JPEG then delegates to caller's onError.

The backend PDFs service does not accept image/heic, so every fallback results in a silent receipt-less expense.

Suggested fix

  1. Stop falling back to raw HEIC — on conversion failure, show a user-facing error (e.g. corrupted/unsupported attachment modal) and block upload.
  2. Investigate Image context has been lost — consider retry logic, avoiding parallel conversions, or keeping the app foregrounded during conversion.
  3. Optionally add a final MIME-type guard before upload to reject any remaining image/heic client-side.

Screenshots/Videos

Add repro video if available (may require multiple attempts due to intermittent nature).

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 10, 2026
  2. MelvinBot commented on Jul 10, 2026

    @MelvinBot
    Contributor

    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/heic on UploadReceipt), so the expense is created receipt-less / stuck on "Scanning…". Confirmed in code:

    The underlying expo-image-manipulator failures (Image context has been lost, Drawing the new image failed, Android JobCancellationException on 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:

    1. In useFilesValidation.tsx, in the onError handler, instead of convertedFiles.push(file), push a validation error to collectedErrors.current (e.g. FILE_CORRUPTED or WRONG_FILE_TYPE — both already defined in CONST.FILE_VALIDATION_ERRORS with user-facing text wired through getFileValidationErrorText). This shows the existing corrupted/unsupported-attachment modal and blocks the bad upload.
    2. In AttachmentPicker/index.native.tsx, replace the raw-asset fallback in the .catch with a user-facing error (this path already has showGeneralAlert available in the sibling catch at L275-278).
    3. Optionally add a final MIME-type guard before upload to reject any lingering image/heic client-side as defense-in-depth.

    Separately (lower priority, does not block the fix above), investigate reducing the Image context has been lost failures — 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)

    • Retry conversion before failing: attempt renderAsync() a second time (and/or serialize conversions instead of Promise.all) before surfacing an error. Reduces the failure rate but doesn't remove the need for the error path in step 1.
    • Server-side accept HEIC: out of scope for App and a much larger change to the PDFs service.
    Related issues (same HEIC root theme, separate root causes)

    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.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 10, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 10, 2026
  5. aswin-s commented on Jul 10, 2026

    @aswin-s
    Contributor

    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-manipulator fails to convert it to JPEG, the app silently falls back to uploading the original HEIC file. The backend rejects it with Unsupported 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 onError callback logs HEIC conversion failed, falling back to original file and then convertedFiles.push(file) (line 240) queues the original HEIC. In src/components/AttachmentPicker/index.native.tsx:263, the .catch block logs Failed to convert HEIC image, falling back to original and pushes processAssetWithFallbacks(asset) (line 264-265) — which is still the unconverted HEIC asset. Because convertHeicImage (src/libs/fileDownload/heicConverter/index.native.ts:61) only reports the error via onError and 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 resulting image/heic payload is rejected by UploadReceipt.

    What changes do you think we should make in order to solve the problem?

    1. src/hooks/useFilesValidation.tsx (~line 238-242): in the convertHeicImage onError callback, do NOT convertedFiles.push(file). Instead, route the file through the existing invalid/unsupported-attachment error path used by useFilesValidation (the same ErrorModal surface 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.
    2. src/components/AttachmentPicker/index.native.tsx (~line 262-267): in the .catch branch, stop calling processAssetWithFallbacks(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 from processedAssets, then checkAllProcessed() so the batch completes without the invalid file.
    3. src/libs/fileDownload/heicConverter/index.native.ts (~line 48-61): keep the current onError contract 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.
    4. As a defense-in-depth guard, add a final MIME-type check right before the receipt/attachment is queued for upload that rejects any file whose type is image/heic or image/heif client-side with the same unsupported-attachment modal, so any future fallback path cannot leak a HEIC to UploadReceipt.
    5. Add unit coverage for both useFilesValidation and AttachmentPicker/index.native that simulates a convertHeicImage failure 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 lost before surfacing the error could recover some intermittent failures, but should be layered on top of the block-on-failure fix, not instead of it.

  6. melvin-bot commented on Jul 10, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (External)

  7. samranahm commented on Jul 10, 2026

    @samranahm
    Contributor

    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:

    1. In useFilesValidation.tsx, when convertHeicImage fails, the onError callback logs "HEIC conversion failed, falling back to original file" and proceeds to return the original file object:
    2. In AttachmentPicker/index.native.tsx, the .catch block for the conversion process logs "Failed to convert HEIC image, falling back to original" and then pushes the original asset for upload:
      .catch((error: Error) => {

    The backend PDF service does not support image/heic files, 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.

    1. Modify useFilesValidation.tsx to prevent falling back to the original HEIC file when convertHeicImage fails. Instead of returning the original file, it should indicate an error, preventing the file from being processed for upload.

      // Current logic:
      // .onError(() => {
      //     Log.info('HEIC conversion failed, falling back to original file');
      //     return file;
      // })
      
      // Proposed change:
      .onError((error) => {
          Log.info('HEIC conversion failed, blocking upload', false, { error });
          // Return null or throw an error to prevent the original file from being used
          // and trigger the appropriate error handling in the calling context.
          throw new Error('HEIC_CONVERSION_FAILED');
      })
    2. Update AttachmentPicker/index.native.tsx to handle conversion failures by blocking the upload and showing a user-facing error. The .catch block should not push the original asset.

      .catch((error: Error) => {

      // Current logic:
      // .catch((error) => {
      //     Log.info('Failed to convert HEIC image, falling back to original', false, {error});
      //     return asset;
      // })
      
      // Proposed change:
      .catch((error) => {
          Log.info('Failed to convert HEIC image, blocking upload', false, {error});
          // Instead of returning asset, we should reject the promise or
          // trigger an error state in the UI, preventing the upload.
          // This might involve calling a prop like `onConversionError` or
          // setting an internal state to display an error modal.
          throw new Error('HEIC_CONVERSION_FAILED');
      })
    3. Introduce a client-side MIME-type validation check in FileUtils.ts within the validateReceipt function, or a similar pre-upload validation, to explicitly reject image/heic files before they are sent to the server. This acts as a final safeguard.

      const validateReceipt = (file: FileObject, setUploadReceiptError: (isInvalid: boolean, title: TranslationPaths, reason: TranslationPaths) => void) => {
      return validateImageForCorruption(file)

      const validateReceipt = (file: FileObject, setUploadReceiptError: (isInvalid: boolean, title: TranslationPaths, reason: TranslationPaths) => void) => {
          if (file.type === 'image/heic' || file.type === 'image/heif') {
              setUploadReceiptError(true, 'attachmentPicker.unsupportedFileType', 'attachmentPicker.unsupportedFileType');
              return false;
          }
          return validateImageForCorruption(file)

    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.

  8. changed the title [-]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[/+] on Jul 10, 2026
  9. melvin-bot commented on Jul 10, 2026

    @melvin-bot
  10. yusufdeveloper2903 commented on Jul 10, 2026

    @yusufdeveloper2903
    Contributor

    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/heic file instead of surfacing an error, so UploadReceipt rejects it with Unsupported file type: image/heic and 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 onError instead of pretending it succeeded, at heicConverter/index.native.ts:47-49:

    .catch((err) => {
        Log.warn('Error converting HEIC/HEIF to JPEG', {error: err instanceof Error ? err.message : String(err)});
        onError(err, file);
    })

    The bug is entirely in the two native callers, which treat that onError as "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): the onError handler logs and pushes the untouched file into convertedFiles, which is then merged into validNonPdfFiles and handed to onFilesValidated for upload:

    onError: () => {
    Log.warn('HEIC conversion failed, falling back to original file', {fileName: file.name});
    convertedFiles.push(file);
    resolve();
    },

    That convertedFiles array is what gets uploaded — see the merge at useFilesValidation.tsx:249 and the onFilesValidated(...) dispatch at useFilesValidation.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 .catch on renderAsync().saveAsync() falls back to processAssetWithFallbacks(asset), which returns the original HEIC asset and pushes it to processedAssets:

    .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();
    });

    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(...) .catch in the very same block already does the right thing — it calls showGeneralAlert(...) and does not enqueue the asset, at AttachmentPicker/index.native.tsx:275-278. And useFilesValidation already has the exact "surface it as a corrupted-file error" precedent it needs for its resize failures, at useFilesValidation.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, Android JobCancellationException on navigation), which matches the reported "intermittent, worse under memory pressure / when navigating away" behavior. The web converter at heicConverter/index.ts:87-89 already calls onError without 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/heic MIME never reaches the server, so the receipt-less expense can't happen.

    1. src/hooks/useFilesValidation.tsx — in the convertHeicImage onError, push a FILE_CORRUPTED error 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 — getFileValidationErrorText already maps FILE_CORRUPTED to attachmentPicker.attachmentError / errorWhileSelectingCorruptedAttachment at FileUtils.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 with showGeneralAlert(...) and skip the asset, exactly like the sibling verifyFileFormat .catch two 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')) before checkAllProcessed() so the user gets a clear message instead of a silent failure.

    This is safe because:

    • Both changes only alter the failure branch — the success paths (onSuccess / the JPEG .then) are untouched, so every currently-working conversion behaves identically.
    • FILE_CORRUPTED already has full modal + copy support in getFileValidationErrorText, and it's the same code the resize-failure path uses, so no new translation keys or components are introduced.
    • The AttachmentPicker change adopts the exact error-surfacing pattern already used by the adjacent verifyFileFormat catch in the same function, so behavior stays consistent within the file.
    • The web flow is already correct and is not touched, so this is scoped precisely to the iOS/Android regression.

    Note: the Image context has been lost errors (~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 via Promise.all at useFilesValidation.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 still image/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 UploadReceipt never receives image/heic and no receipt-less expense is created.

    What alternative solutions did you explore? (Optional)

    • Keep the fallback but let the server reject and show the error afterwards — rejected: the expense is already optimistically created by then, so the user is left with a "Scanning…"/"Receipt upload failed" expense; blocking client-side before upload is both cheaper and clearer, and is what every other unsupported/corrupted case already does.
    • Transcode the HEIC to JPEG on the backend instead — rejected as the primary fix: it's a larger cross-repo change and still uploads a file the PDFs service currently rejects; the client already owns HEIC conversion, so the minimal correct fix is to not defeat it on failure. A MIME guard/BE transcode can be layered on later.
    • Only fix useFilesValidation (the RCA the issue body emphasizes) — rejected as incomplete: production logs show ~235/week failures from AttachmentPicker vs ~189 from useFilesValidation, so a fix that skips the camera-roll/Scan path in AttachmentPicker/index.native.tsx leaves the majority of the failures in place.
  11. KJ21-ENG commented on Jul 10, 2026

    @KJ21-ENG
    Contributor

    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 calls onError when ImageManipulator fails, but useFilesValidation logs that error and pushes the original .heic/.heif file into convertedFiles, which is later appended to the valid upload list.

    convertHeicImage(file, {
    onSuccess: (convertedFile) => {
    if (validationState.isValidatingReceipts && convertedFile.size && convertedFile.size > CONST.API_ATTACHMENT_VALIDATIONS.RECEIPT_MAX_SIZE) {
    convertedFilesToResize.push(convertedFile);
    resolve();
    return;
    }
    if (!validationState.isValidatingReceipts && convertedFile.size && convertedFile.size > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) {
    collectedErrors.current.push({
    error: CONST.FILE_VALIDATION_ERRORS.FILE_TOO_LARGE,
    isValidatingMultipleFiles: validationState.isValidatingMultipleFiles,
    });
    resolve();
    return;
    }
    convertedFiles.push(convertedFile);
    resolve();
    },
    onError: () => {
    Log.warn('HEIC conversion failed, falling back to original file', {fileName: file.name});
    convertedFiles.push(file);
    resolve();
    },
    });
    }),
    ),
    );
    filesToResize.push(...convertedFilesToResize);
    validNonPdfFiles.push(...convertedFiles);

    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 to processedAssets, so the downstream upload still receives the raw HEIC file.

    if (asset.type?.startsWith('image')) {
    verifyFileFormat({fileUri: asset.uri, formatSignatures: CONST.HEIC_SIGNATURES})
    .then((isHEIC) => {
    // react-native-image-picker incorrectly changes file extension without transcoding the HEIC file, so we are doing it manually if we detect HEIC signature
    if (isHEIC && asset.uri) {
    ImageManipulator.manipulate(asset.uri)
    .renderAsync()
    .then((manipulatedImage) => manipulatedImage.saveAsync({format: SaveFormat.JPEG}))
    .then((manipulationResult) => {
    const uri = manipulationResult.uri;
    const convertedAsset = {
    uri,
    name: uri
    .substring(uri.lastIndexOf('/') + 1)
    .split('?')
    .at(0),
    type: 'image/jpeg',
    width: manipulationResult.width,
    height: manipulationResult.height,
    };
    processedAssets.push(convertedAsset);
    checkAllProcessed();
    })
    .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();
    });

    The shared native converter is not the layer creating the bad upload candidate: it reports conversion failure through onError and leaves the caller to decide what to do.

    const imageManipulatorContext = ImageManipulator.manipulate(sourceUri);
    imageManipulatorContext
    .renderAsync()
    .then((manipulatedImage) => manipulatedImage.saveAsync({format: SaveFormat.JPEG}))
    .then((manipulationResult) => {
    const convertedFile = {
    uri: manipulationResult.uri,
    name: file.name?.replace(originalExtension, '.jpg') ?? 'converted-image.jpg',
    type: 'image/jpeg',
    size: file.size,
    width: manipulationResult.width,
    height: manipulationResult.height,
    };
    onSuccess(convertedFile);
    })
    .catch((err) => {
    Log.warn('Error converting HEIC/HEIF to JPEG', {error: err instanceof Error ? err.message : String(err)});
    onError(err, file);
    })
    .finally(() => {
    onFinish();
    });

    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.

    function isFileUploadable(file: FileObject | undefined): boolean {
    // Native platforms only require the object to include the `uri` property.
    // Optionally, it can also have a `name` and `type` properties.
    // On other platforms, the file must be an instance of `Blob` or one of its subclasses.
    return !!file && 'uri' in file && !!file.uri && typeof file.uri === 'string';
    }

    if (key === 'receipt') {
    const {source, name, type, uri} = value as File;
    if (source) {
    return checkFileExists(source).then((exists) => {
    if (!exists) {
    Log.alert('[prepareRequestPayload] Receipt file missing at upload time', {command, source, fileName: name});
    return;
    }
    const receiptFormData = {
    uri,
    name,
    type,
    };
    validateFormDataParameter(command, key, receiptFormData);
    formData.append(key, receiptFormData as File);
    });

    What changes do you think we should make in order to solve the problem?

    In useFilesValidation, change the convertHeicImage onError handler so it does not push the original file into convertedFiles. Instead, add a FILE_CORRUPTED validation 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.

    case CONST.FILE_VALIDATION_ERRORS.FILE_CORRUPTED:
    return {
    title: translate('attachmentPicker.attachmentError'),
    reason: translate('attachmentPicker.errorWhileSelectingCorruptedAttachment'),
    };

    In AttachmentPicker/index.native.tsx, change the HEIC conversion .catch so it shows the same attachment error and does not add processAssetWithFallbacks(asset) to processedAssets. After checkAllProcessed(), the existing processedAssets.length > 0 ? processedAssets : undefined / onCanceled behavior will prevent the failed single asset from reaching pickAttachment, while preserving any other successfully processed assets in multi-select.

    const checkAllProcessed = () => {
    processedCount++;
    if (processedCount === assets.length) {
    resolve(processedAssets.length > 0 ? processedAssets : undefined);
    }
    };
    for (const asset of assets) {
    if (!asset.uri) {
    checkAllProcessed();
    continue;
    }
    if (asset.type?.startsWith('image')) {
    verifyFileFormat({fileUri: asset.uri, formatSignatures: CONST.HEIC_SIGNATURES})
    .then((isHEIC) => {
    // react-native-image-picker incorrectly changes file extension without transcoding the HEIC file, so we are doing it manually if we detect HEIC signature
    if (isHEIC && asset.uri) {
    ImageManipulator.manipulate(asset.uri)
    .renderAsync()
    .then((manipulatedImage) => manipulatedImage.saveAsync({format: SaveFormat.JPEG}))
    .then((manipulationResult) => {
    const uri = manipulationResult.uri;
    const convertedAsset = {
    uri,
    name: uri
    .substring(uri.lastIndexOf('/') + 1)
    .split('?')
    .at(0),
    type: 'image/jpeg',
    width: manipulationResult.width,
    height: manipulationResult.height,
    };
    processedAssets.push(convertedAsset);
    checkAllProcessed();
    })
    .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();
    });
    } else {
    // Ensure the asset has proper fileName and type for non-HEIC images
    const processedAsset = processAssetWithFallbacks(asset);
    processedAssets.push(processedAsset);
    checkAllProcessed();
    }
    })
    .catch((error: Error) => {
    showGeneralAlert(error.message ?? 'An unknown error occurred');
    checkAllProcessed();
    });
    } else {
    // Ensure the asset has proper fileName and type
    const processedAsset = processAssetWithFallbacks(asset);
    processedAssets.push(processedAsset);
    checkAllProcessed();
    }
    }
    });
    }),

    /**
    * An attachment error dialog when user selected malformed images
    */
    const showImageCorruptionAlert = useCallback(() => {
    Alert.alert(translate('attachmentPicker.attachmentError'), translate('attachmentPicker.errorWhileSelectingCorruptedAttachment'));
    }, [translate]);
    /**
    * Handles errors during image processing (resize, dimension check, etc.)
    */
    const handleImageProcessingError = useCallback(
    (error: unknown) => {
    const errorMessage = error instanceof Error ? error.message : undefined;
    if (errorMessage === CONST.FILE_VALIDATION_ERRORS.IMAGE_DIMENSIONS_TOO_LARGE) {
    showGeneralAlert(translate('attachmentPicker.imageDimensionsTooLarge'));
    } else if (errorMessage) {
    showGeneralAlert(errorMessage);
    } else {
    showImageCorruptionAlert();
    }
    return null;

    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/.heif or image/heic/image/heif receipt 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:

    • Add a unit test for useFilesValidation with a mocked convertHeicImage failure proving a HEIC receipt is not passed to onFilesValidated and FILE_CORRUPTED is surfaced.
    • Add/cover the native AttachmentPicker HEIC conversion catch path with a mocked ImageManipulator rejection, proving the raw asset is not passed to completeAttachmentSelection and the attachment error is shown.
    • Add a regression test for the final HEIC MIME/extension guard so an image/heic receipt cannot be submitted even if a platform picker supplies misleading metadata.

    What alternative solutions did you explore? (Optional)

    I considered changing convertHeicImage itself to automatically return an error file or throw, but its current callback contract is correct: it detects the conversion failure and reports it via onError; 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.

  12. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

    ⚠️ @KJ21-ENG Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  13. trasnake87 commented on Jul 10, 2026

    @trasnake87
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  14. 46 remaining items

  15. mallenexpensify commented on Aug 20, 2026

    @mallenexpensify
    Contributor

    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

  16. annaweber830 commented on Aug 25, 2026

    @annaweber830
    Contributor

    Thanks, @mallenexpensify. I've accepted the offer.

  17. mallenexpensify commented on Aug 26, 2026

    @mallenexpensify
    Contributor

    @annaweber830 paid, summary updated above. Thx.

  18. flaviadefaria commented on Sep 2, 2026

    @flaviadefaria
    Contributor

    Approved: @FitseTLT due $250 via NewDot

  19. added
    ReviewingHas a PR in review
    and removed on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions