Skip to content

[Due for payment 2026-03-17] [$250] Scan - Save button loads infinitely when photo is cropped to the smallest size #83709

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.27-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #81380
Email or phone of affected tester (no customers): osidnjodjosijsoji@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

  1. Open staging.new.expensify.com
  2. Go to workspace chat.
  3. Click + > Create expense > Scan.
  4. Upload a photo.
  5. On confirm page, click on the receipt.
  6. Click Crop.
  7. Crop it to the smallest and tap Save.
  8. Repeat Step 6 to 7 a few times.

Expected Result:

Save button will not load infinitely when photo is cropped to the smallest.
Error should show up if the smallest size is not accepted.

Actual Result:

Save button loads infinitely when photo is cropped to the smallest.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7090165_1772206230353.5.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @trjExpensify / bfitzexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022027413879430107482
  • Upwork Job ID: 2027413879430107482
  • Last Price Increase: 2026-02-27
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Feb 27, 2026
  2. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #81380

  3. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. github-actions commented on Feb 27, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on Feb 27, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When cropping a scanned receipt to the smallest possible size, the Save button loads infinitely. No error is shown to the user and there is no way to recover other than canceling out of the crop flow.

    What is the root cause of that problem?

    The cropOrRotateImage function (both web and native) wraps manipulateAsync inside a new Promise((resolve) => { ... }) with no reject parameter, and calls manipulateAsync(...).then(...) with no .catch().

    When the user crops to the smallest size, the crop dimensions (in image coordinates) can become zero or near-zero due to floating-point arithmetic — the UI enforces a minimum of 24 display pixels (cornerHandleSize * 2), but after conversion to image coordinates via float multiplication, canvas operations can truncate these to 0. This causes expo-image-manipulator's CropAction to throw ERR_IMAGE_MANIPULATOR_CROP ("Crop size must be greater than 0"), or saveAsync to reject because canvas.toBlob() returns null on a zero-dimension canvas.

    When manipulateAsync rejects, the .then() inside cropOrRotateImage is skipped, and the rejection goes unhandled inside the Promise constructor. Since the constructor only takes resolve (no reject), the outer promise never settles — it neither resolves nor rejects. This means saveCrop's .then() and .catch() in TransactionReceiptModalContent.tsx never fire, so setIsCropSaving(false) is never called, leaving the Save button in a permanent loading state.

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

    Two changes:

    1. Fix the Promise constructor anti-pattern in cropOrRotateImage — In both src/libs/cropOrRotateImage/index.ts and src/libs/cropOrRotateImage/index.native.ts, refactor to use async/await (or add reject to the Promise constructor and .catch(reject) to the inner chains) so that errors from manipulateAsync properly propagate. This ensures saveCrop's .catch() fires and resets isCropSaving to false.

    2. Add minimum crop dimension validation — In ReceiptCropView or in saveCrop, validate that the crop dimensions in image coordinates are at least 1 pixel (e.g., Math.max(1, Math.round(width))) before passing them to cropOrRotateImage. This prevents the crop from being attempted with zero dimensions in the first place.

    What alternative solutions did you explore? (Optional)

    • Only adding validation without fixing the Promise: This would prevent the specific zero-dimension trigger, but other failures in manipulateAsync (e.g., network issues loading the image, out-of-memory) would still cause infinite loading. The Promise fix is essential.
    • Showing an error toast when crop dimensions are too small instead of attempting the crop: This would be a nice UX improvement but doesn't address the underlying Promise bug.

    Note: The rotateReceipt function uses the same cropOrRotateImage path and has the identical vulnerability — if rotation fails, isRotating would also get stuck.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  7. 52 remaining items

  8. hungvu193 commented on Mar 17, 2026

    @hungvu193
    Contributor

    No checklist needed, this was caught by the regression test in #81380

  9. trjExpensify commented on Mar 17, 2026

    @trjExpensify
    Contributor

    We still fill out the checklist and do the other parts, like commenting on the PR that introduced the bug.

  10. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Issue is ready for payment but no BZ is assigned. @mallenexpensify you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

  11. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2027413879430107482/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. hungvu193 commented on Mar 18, 2026

    @hungvu193
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/81380/changes#r2950559935

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    No regression test needed

  13. mallenexpensify commented on Mar 18, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @hungvu193 paid $250 via Upwork
    Contributor+: @eh2077 due $250 via NewDot

  14. twisterdotcom commented on Mar 19, 2026

    @twisterdotcom
    Contributor

    @hungvu193 has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-12bb-a381-aac0-52ce93c44cd4
  15. JmillsExpensify commented on Mar 24, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @eh2077

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.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions