Skip to content

Fix distance e-receipt overlay showing after editing when cursor hovers over image - #93943

Merged
mountiny merged 2 commits into
Expensify:mainfrom
software-mansion-labs:fix/93748
Jun 22, 2026
Merged

mountiny merged 2 commits into
Expensify:mainfrom
software-mansion-labs:fix/93748

Conversation

@WojtekBoman

@WojtekBoman WojtekBoman commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

After a distance expense edit the receipt image reloads with a new source URL. If the cursor was already over the map image before the reload, hovered remained true across the loading cycle, causing HoveredDistanceEReceipt to flash immediately when the new map finished loading — without the user moving the pointer. Added pointerMovedAfterLoad state that resets on each source change and is set only on onMouseMove, so the overlay only appears after the cursor actively moves over the image.

Screen.Recording.2026-06-18.at.17.11.34.mov

Fixed Issues

$ #93748
PROPOSAL:

Tests

Bug fix — overlay must not appear when cursor is parked under a newly-loaded map

  1. Open an expense report that contains a distance (map-based) expense.
  2. Open the expense detail view so the map receipt thumbnail is visible.
  3. Move the cursor over the map image and keep it stationary (do not move it after entering the image).
  4. Edit any distance field (e.g. a waypoint address) and save.
  5. While the updated map is loading, keep the cursor stationary over the image area.
  6. Verify that when the new map finishes loading, the full HoveredDistanceEReceipt overlay (e-receipt card with amount and waypoints) does not appear automatically.
  7. Now move the cursor over the image — verify that the overlay does appear while the cursor is moving, and disappears when the cursor leaves the image.

Regression — normal hover zoom still works

  1. Open a distance expense detail view with the map receipt thumbnail visible.
  2. Move the cursor onto the map image from outside the image boundary.
  3. Verify that moving the cursor over the image triggers the zoom effect and shows the HoveredDistanceEReceipt overlay.
  4. Move the cursor off the image — verify the overlay disappears.
  • Verify that no errors appear in the JS console

Offline tests

N/A — this change is purely a hover/UI interaction with no API calls or Onyx operations.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@WojtekBoman WojtekBoman changed the title Fix distance e-receipt overlay showing after editing when cursor is p… Fix distance e-receipt overlay showing after editing when cursor is parked over image Jun 18, 2026
@WojtekBoman WojtekBoman changed the title Fix distance e-receipt overlay showing after editing when cursor is parked over image Fix distance e-receipt overlay showing after editing when cursor hovers over image Jun 18, 2026
@WojtekBoman

Copy link
Copy Markdown
Contributor Author

@codex

@codecov

codecov Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/components/ReceiptHoverZoom/index.tsx 100.00% <100.00%> (ø)
...components/ReceiptHoverZoom/useReceiptHoverZoom.ts 97.22% <100.00%> (+0.44%) ⬆️
src/components/ReceiptHoverZoom/index.web.tsx 0.00% <0.00%> (ø)
...nents/ReportActionItem/MoneyRequestReceiptView.tsx 69.47% <75.00%> (-0.04%) ⬇️
... and 110 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d1c99d254

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// the cursor is already over the receipt (e.g. after closing the RHP) or `onMouseEnter` fires
// while the receipt is still loading, no new `mouseenter` event occurs, so we re-sync on mouse move.
onMouseMove={() => {
setPointerMovedAfterLoad(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore mouse moves while the receipt is still loading

Because this flag is set before checking isLoading, any small cursor movement over the receipt while the new map is still loading marks pointerMovedAfterLoad as true. In that scenario the distance overlay can appear during the reload or immediately when onLoad flips isLoading false, even though the user has not moved the pointer after the newly loaded map is ready, which defeats the guard added for edited distance receipts.

Useful? React with 👍 / 👎.

@WojtekBoman
WojtekBoman marked this pull request as ready for review June 18, 2026 15:12
@WojtekBoman
WojtekBoman requested review from a team as code owners June 18, 2026 15:12
@melvin-bot
melvin-bot Bot requested review from QichenZhu and joekaufmanexpensify and removed request for a team and joekaufmanexpensify June 18, 2026 15:12
@melvin-bot

melvin-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

@QichenZhu Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@github-actions

Copy link
Copy Markdown
Contributor

🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7dd9a9fe91

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return;
}
setIsLoading(true);
setPointerMovedAfterLoad(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reset hover gate before pending regeneration clears

This reset only runs after receipt.source changes, but in the distance-edit path UpdateMoneyRequest clears the regeneration pendingFields on API success before the Pusher update that delivers the new receipt.source. If the user had already moved over the old map and keeps the cursor parked, pointerMovedAfterLoad remains true when canShowDistanceEReceipt flips back to true, so the overlay can still reappear automatically during that API-success→source-update gap; reset the gate when regeneration starts or while those pending fields are present, not only after the source changes.

Useful? React with 👍 / 👎.

@github-actions

This comment has been minimized.

@mountiny

Copy link
Copy Markdown
Contributor

@MelvinBot Review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The approach is sound and correctly fixes the issue. Gating HoveredDistanceEReceipt behind a new pointerMovedAfterLoad flag that resets on every receipt source change is a clean way to require an active pointer move before showing the overlay, given that useHover's hovered can't be reset to false here without re-triggering. The fix also handles repeated edits (the flag resets on each source change), and normal hover-from-outside still works because onMouseEnter is immediately followed by onMouseMove.

✅ LGTM on logic — a few non-blocking points below.

Verification of the fix path
  • Bug scenario: source change → setIsLoading(true); setPointerMovedAfterLoad(false) → on load, the isLoading effect re-syncs hovered=true, but pointerMovedAfterLoad is still false, so the overlay stays hidden. First real onMouseMove flips the flag → overlay appears. ✓
  • Normal hover: onMouseEnter (hovered) + subsequent onMouseMove (flag) → overlay appears. ✓
  • Repeated edits while parked: each source change resets the flag, so it stays hidden every cycle. ✓

Non-blocking

  1. No unit test in the diff. The PR is a single-file change but the author checklist claims a unit test was added. There's already an useReceiptHoverZoomTest.ts; a small test asserting the overlay doesn't render when hovered is true but pointerMovedAfterLoad is false would lock in this regression fix.

  2. Diff noise — two unrelated cosmetic changes that don't affect behavior and could be reverted to keep the diff minimal:

    • onMouseLeave was wrapped in an arrow function (() => { hoverBind.onMouseLeave(); }) — functionally identical to the prior onMouseLeave={hoverBind.onMouseLeave}.
    • The elementHovered extraction inlines the same isElementHovered(receiptContainerRef) call into a local with no added clarity.
  3. Minor behavior note (likely fine): on first open of an expense, if the cursor happens to already be parked over the receipt when it finishes loading, the overlay now won't appear until the pointer moves. This matches the intent of the fix (require active movement) and is an edge case, so no change needed — just confirming it's intentional.


Next Steps: Reply with @MelvinBot <feedback> to refine, or address the points above. This is a code review only — I did not run the manual hover/reload test steps; those still need a human pass on web.

@QichenZhu

QichenZhu commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

2. Diff noise — two unrelated cosmetic changes that don't affect behavior and could be reverted to keep the diff minimal:

  • onMouseLeave was wrapped in an arrow function (() => { hoverBind.onMouseLeave(); }) — functionally identical to the prior onMouseLeave={hoverBind.onMouseLeave}.
  • The elementHovered extraction inlines the same isElementHovered(receiptContainerRef) call into a local with no added clarity.

Agreed with the bot's second point, otherwise this works well.

Screen.Recording.2026-06-19.at.3.54.03.PM.mov

@QichenZhu QichenZhu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two separate components: one handles zoom and the other handles the map/receipt flip, and they update independently.

Should we make one control the other, or have one read the other's state, so there is a single source of truth and they are always in sync?

@WojtekBoman

Copy link
Copy Markdown
Contributor Author

We have two separate components: one handles zoom and the other handles the map/receipt flip, and they update independently.

Should we make one control the other, or have one read the other's state, so there is a single source of truth and they are always in sync?

Good call! I've made ReceiptHoverZoom the single source of truth, it now tracks the hover state internally and exposes it via a render prop, so the e-receipt overlay just reads that instead of tracking hover on its own. Let me know if it's ok for you :)

@mountiny

Copy link
Copy Markdown
Contributor

@QichenZhu can you review again please

@QichenZhu

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
    https://expensify.slack.com/archives/C049HHMV9SM/p1778663561704459
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen_recording_20260622_211342.webm
Android: mWeb Chrome
Screen_recording_20260622_211454.webm
iOS: HybridApp
Simulator.Screen.Recording.-.iPhone.17.-.2026-06-22.at.21.07.21.mov
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.17.-.2026-06-22.at.21.08.28.mov
MacOS: Chrome / Safari
Screen.Recording.2026-06-22.at.9.05.36.PM.mov

@melvin-bot
melvin-bot Bot requested a review from mountiny June 22, 2026 09:18
@mountiny
mountiny merged commit bba3006 into Expensify:main Jun 22, 2026
33 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.17-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site review: no docs changes required.

This PR is an internal UI bug fix. It adds a shared isHovering state to the ReceiptHoverZoom component (and a pointerMovedAfterLoad/canHoverZoomReceipt guard) so the distance e-receipt overlay no longer flashes when the cursor is parked over a map receipt that reloads after a distance edit. The overlay now only appears after the pointer actively moves over the image.

There are no user-facing changes — no new features, settings, tab names, button labels, or workflow changes — so nothing in docs/articles describes this behavior or needs updating. I searched the help site for related content (distance expenses, e-receipts, hover) and found only incidental mentions in unrelated articles; none document the receipt hover-zoom interaction.

No draft docs PR was created.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.4.17-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

1 similar comment
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.4.17-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants