Skip to content

[Due for payment 2025-11-19] [$250] Scan - receipt picture not display full image as seen at the time of capture #71644

Closed

Description

@jponikarchuk

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: v9.2.21-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1105/folder/13176933/41237723/927170986
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: iPhone 16 pro/ 18.6.2
App Component: Money Requests

Action Performed:

Precondition: Open file PDF on computer

  1. Open app
  2. Navigate to any conversation or workspace chat
  3. Tap on + button and select Create expense
  4. Tap on Scan tab
  5. Rotate your phone to landscape mode
  6. Adjust for seen image on computer with largest and fully
  7. Take photo
  8. Tap on receipt picture

Expected Result:

The image displays fully as seen in the viewfinder at the time of capture

Actual Result:

The image is cut off, not display fully as seen at the time of capture

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

11.mp4
Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021975356266177322593
  • Upwork Job ID: 1975356266177322593
  • Last Price Increase: 2025-10-14
  • Automatic offers:
    • truph01 | Reviewer | 109155709
    • gijoe0295 | Contributor | 109155711
Issue OwnerCurrent Issue Owner: @strepanier03

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 1, 2025
  2. melvin-bot commented on Oct 1, 2025

    @melvin-bot

    Triggered auto assignment to @strepanier03 (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.

  3. gijoe0295 commented on Oct 1, 2025

    @gijoe0295
    Contributor

    Proposal

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

    Receipt picture not display full image as seen at the time of capture

    What is the root cause of that problem?

    After capturing the photo, we try to crop it to exactly fit in the preview container in this function:

    function cropImageToAspectRatio(
    /** Source image */
    image: ImageObject,
    /** Width portion of the target aspect ratio (e.g., 16 for 16:9) */
    aspectRatioWidth?: number,
    /** Height portion of the target aspect ratio (e.g., 9 for 16:9) */
    aspectRatioHeight?: number,
    /** Vertically align the crop to the top (true) or center (false) */
    shouldAlignTop?: boolean,
    ): Promise<ImageObject> {

    But we haven't taken into account that the preview container (defined by aspectRatioWidth and aspectRatioHeight) can also be rotated (just like image). In this case, even after rotating, the preview container width and height remain the same (it should be exchanged width >> height and height >> width).

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

    This issue only happens on Android and iOS, on Web, the container size after rotation is automatically handled. The general idea is simple: If the photo is rotated, we need to switch the viewport width and height:

    const ratioWidth = isRotated? aspectRatioWidth : aspectRatioHeight;
    const ratioHeight = isRotated? aspectRatioHeight: aspectRatioWidth;

    The problem is isRotated.

    • On Android, we can rely on the rotation value returned by react-native-image-size:

    That is already working:

    const isRotated = imageSize?.rotation === 90 || imageSize?.rotation === 270;

    • iOS uses RN built-in Image.getSize which only provides width and height. So we need to rely on the photo.orientation returned by react-native-vision-camera:

    orientation can have these values:

    - `portrait`: **0°** (home-button at the bottom)
    - `landscape-left`: **90°** (home-button on the left)
    - `portrait-upside-down`: **180°** (home-button at the top)
    - `landscape-right`: **270°** (home-button on the right)
    
    • Web is same as iOS (no rotation support) but it already auto handles the width/height switching for the view container so we can ignore it.

    So based on that, we need to create platform-specific files isRotated that determines rotation:

    • Web: Always 0
    • Android: Same as current logic:

    const isRotated = imageSize?.rotation === 90 || imageSize?.rotation === 270;

    • iOS:
    const isRotated = orientation === 'landscape-left' || orientation === 'landscape-right';

    Then pass those actual ratioWidth and ratioHeight to calculateCropRect:

    const crop = calculateCropRect(imageWidth, imageHeight, aspectRatioWidth, aspectRatioHeight, shouldAlignTop);

    What alternative solutions did you explore? (Optional)

    None

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 7, 2025
  5. changed the title [-]Scan - receipt picture not display full image as seen at the time of capture[/-] [+][$250] Scan - receipt picture not display full image as seen at the time of capture[/+] on Oct 7, 2025
  6. melvin-bot commented on Oct 7, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 7, 2025
  8. melvin-bot commented on Oct 7, 2025

    @melvin-bot

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

  9. strepanier03 commented on Oct 7, 2025

    @strepanier03
    Contributor

    Able to repro okay.

  10. 34 remaining items

  11. melvin-bot commented on Nov 12, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  12. melvin-bot commented on Nov 12, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.54-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-11-19. 🎊

    For reference, here are some details about the assignees on this issue:

  13. melvin-bot commented on Nov 12, 2025

    @melvin-bot

    @truph01 @strepanier03 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. strepanier03 commented on Nov 19, 2025

    @strepanier03
    Contributor

    Payment Summary

  15. gijoe0295 commented on Nov 19, 2025

    @gijoe0295
    Contributor

    Het @strepanier03 I'm paid via NewDot now so I'll request later on due date. Matt Allen also told me to link this internal GH in case the automatic offer has been sent. Thank you

  16. truph01 commented on Nov 19, 2025

    @truph01
    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:

    • [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:

    • [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.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    1. Test on mobile only
    2. Rotate your phone to landscape mode (make sure device's rotation lock is not enabled)
    3. FAB -> Create expense -> Scan
    4. Grant camera permission if needed
    5. Press capture
    6. Press the receipt preview
    7. Verify what you saw on the camera preview in step 4 is captured fully in the receipt

    Do we agree 👍 or 👎

  17. strepanier03 commented on Nov 21, 2025

    @strepanier03
    Contributor

    Thanks for letting me know @gijoe0295 - I ended the contract in Upwork, so it's not sitting in your dashboard.

    I updated the payment summary and removed the hold.

  18. JmillsExpensify commented on Nov 26, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @gijoe0295

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