Skip to content

[Due for payment 2025-08-13] [$250] iOS - Wrong horizontal padding when opening a receipt while creating expenses with Multi-Scan #65251

Closed

Description

@cristipaval

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:
Reproducible in staging?:
Reproducible in production?: New feature, not in prod yet
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dubielzyk-expensify
Slack conversation (hyperlinked to channel name):

Action Performed:

  1. Global Create -> Create expense
  2. On the Scan tab, enable the Multi-Scan
  3. Take a few pictures in a row
  4. Tap on a receipt from the bottom carousel with the receipt previews

Expected Result:

No horizontal padding should be there

Actual Result:

There is a horizontal padding

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Image

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @dylanexpensify

Activity

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

    @melvin-bot

    Triggered auto assignment to @slafortune (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. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 1, 2025
  4. changed the title [-]iOS - Wrong horizontal padding when opening a receipt while creating expenses with Multi-Scan[/-] [+][$250] iOS - Wrong horizontal padding when opening a receipt while creating expenses with Multi-Scan[/+] on Jul 1, 2025
  5. melvin-bot commented on Jul 1, 2025

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

    @melvin-bot

    Current assignee @dukenv0307 is eligible for the External assigner, not assigning anyone new.

  8. MobileMage commented on Jul 1, 2025

    @MobileMage
    Contributor

    Proposal

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

    When using Multi-Scan to create expenses on iOS, opening a receipt from the bottom carousel shows incorrect horizontal padding. The first carousel item displays correctly, but after swiping to other items and returning, the images appear smaller with unwanted horizontal padding. This only affects the carousel version of the lightbox - the confirmation screen displays correctly.

    What is the root cause of that problem?

    The issue is in the Lightbox component's contentSize caching mechanism. When images become invisible during carousel navigation, their cached dimensions get corrupted with undefined values. Here's the problematic sequence:

    1. Initial load: Image loads with correct dimensions (525x700)
    2. Swipe: Image becomes invisible, cache gets poisoned with undefined
    3. Return: Image loads again but gets wrong dimensions from cache corruption
    4. Result: Wrong contentSize causes incorrect scaling and horizontal padding

    The cache is being shared across different images, and when one image's lightbox becomes invisible, it overwrites the cache with undefined values that then affect other images.

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

    Fix the contentSize caching logic in src/components/Lightbox/index.tsx to prevent cache corruption:

    // Clear cache when component unmounts
    useEffect(() => {
        return () => {
            cachedImageDimensions.delete(uri);
        };
    }, [uri]);
    
    // When lightbox becomes invisible, only reset local state, not cache
    useEffect(() => {
        if (isLightboxVisible) {
            return;
        }
        setLightboxImageLoaded(false);
        setInternalContentSize(cachedImageDimensions.get(uri));
    }, [isLightboxVisible, uri]);
    
    // Don't cache undefined values
    const setContentSize = useCallback(
        (newDimensions: ContentSize | undefined) => {
            setInternalContentSize(newDimensions);
            if (newDimensions !== undefined) {
                cachedImageDimensions.set(uri, newDimensions);
            }
        },
        [uri],
    );
    
    // Always update with actual loaded dimensions
    const updateContentSize = useCallback(
        ({nativeEvent: {width, height}}: ImageOnLoadEvent) => {
            const newDimensions = {width, height};
            setContentSize(newDimensions);
        },
        [setContentSize, uri],
    );

    Result

    Kapture.2025-07-06.at.17.28.57.mp4

    The key changes are: stop caching undefined values, preserve cached dimensions when lightbox becomes invisible, and always update with actual loaded dimensions instead of conditionally skipping updates.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Test carousel navigation with multiple images to ensure contentSize consistency is maintained after swiping between items.

    What alternative solutions did you explore? (Optional)

    N/A

  9. MobileMage commented on Jul 1, 2025

    @MobileMage
    Contributor

    Proposal

    Updated here

  10. 52 remaining items

  11. changed the title [-][$250] iOS - Wrong horizontal padding when opening a receipt while creating expenses with Multi-Scan[/-] [+][Due for payment 2025-08-13] [$250] iOS - Wrong horizontal padding when opening a receipt while creating expenses with Multi-Scan[/+] on Aug 6, 2025
  12. melvin-bot commented on Aug 6, 2025

    @melvin-bot

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

  13. melvin-bot commented on Aug 6, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.89-21 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-08-13. 🎊

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

    • @VickyStash does not require payment (Contractor)
    • @dukenv0307 requires payment through NewDot Manual Requests
  14. melvin-bot commented on Aug 6, 2025

    @melvin-bot

    @dukenv0307 @dylanexpensify 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]

  15. dukenv0307 commented on Aug 7, 2025

    @dukenv0307
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [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: Edge case

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

    Regression Test Proposal Template
    • [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

    Test:

    • Mobile/mWeb:
    1. Global Create -> Create expense
    2. On the Scan tab, enable the Multi-Scan
    3. Take a few pictures in a row
    4. Tap on a receipt from the bottom carousel with the receipt previews
    5. Make sure the receipt has no extra horizontal padding
    • All platforms:
    1. Open any report
    2. Send a big-picture attachment (example)
    3. After the attachment is uploaded, open the attachment
    4. Verify that the high-resolution info text is displayed correctly

    Do we agree 👍 or 👎

  16. dylanexpensify commented on Aug 13, 2025

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor+: @dukenv0307 $250 via NewDot

    Please apply/request!

  17. melvin-bot commented on Aug 13, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    • Contributor: @VickyStash is from an agency-contributor and not due payment
    • Reviewer: @dukenv0307 owed $250 via NewDot

    BugZero Checklist (@dylanexpensify)

    • 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//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
  18. garrettmknight commented on Aug 20, 2025

    @garrettmknight
    Contributor

    $250 approved for @dukenv0307

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.DailyKSv2ExternalAdded 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