Skip to content

Prevent Home chart refresh when cancelling an expense panel - #107382

Merged
inimaga merged 2 commits into
mainfrom
claude-homeInsightsRhpFocus
Nov 23, 2026
Merged

inimaga merged 2 commits into
mainfrom
claude-homeInsightsRhpFocus

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Keep the original tab logically focused while an expense destination is pre-mounted beneath an RHP. Otherwise cancellation looks like leaving and returning to Home, incorrectly refreshing its Insights chart. The saved tab is used only for a matching navigator key with an RHP above it; genuine tab switches and committed submissions retain their normal refresh behavior.

Also clean up speculative navigation before Escape dismisses an RHP. Escape previously left restoration to unmount cleanup, allowing the destination to become briefly focused before a deferred return to Home. This is limited to cancellation rather than changing generic modal dismissal, which is also used for successful reveals.

Implementation: useIsTabFocused.ts:19–35 and EscapeHandler.tsx:89–95.

Fixed Issues

$ #106873
PROPOSAL: #106873 (comment)

Tests

Precondition: Account A is the owner of a workspace with enough expenses to populate Home Insights. Account B is a member of the workspace submitting to Account A, so that expenses from B can alter Account A's Insights.

  1. Open Expensify on staging as Account A (use a narrow browser window when testing on web).
  2. Go to Home and scroll to the Insights chart.
  3. Open the RHP, for example, select + > Create expense.
  4. In a different session as Account B, submit an expense to the workspace.
  5. As Account A, close the RHP without creating or changing an expense.
  6. Verify that the chart does not refresh when the panel is closed.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Precondition: Account A is the owner of a workspace with enough expenses to populate Home Insights. Account B is a member of the workspace submitting to Account A, so that expenses from B can alter Account A's Insights.

  1. Open Expensify on staging as Account A (use a narrow browser window when testing on web).
  2. Go to Home and scroll to the Insights chart.
  3. Open the RHP, for example, select + > Create expense.
  4. In a different session as Account B, submit an expense to the workspace.
  5. As Account A, close the RHP without creating or changing an expense.
  6. Verify that the chart does not refresh when the panel is closed.
  • 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 verified any copy / text that was added to the app 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 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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.

AI Tests

Main sync — 2026-11-23: Merged main at 5de42f69e315de80aee82d2fdf01b283034ea8b6 without conflicts; pushed merge commit c46a1e04e139642beddea32ea2d2914c54660993. No manual conflict resolutions or additional implementation changes.

  • Passed: 10 tab-focus unit tests; Storybook smoke test; commit-hook formatting; whitespace check against merged main. Staged code review reported no violations.

  • Blocked: the other two focused suites failed to load because Jest attempted to require the React Navigation core ES module. The full Jest run also failed; no full-suite pass is claimed.

  • Tooling limits: initial lint/typecheck attempts encountered missing Skia dependencies. After npm ci, lint, changed-file lint, typecheck, and React Compiler checks could not run because Bun's postinstall had not run. The required prettier script is absent. Changed-file spelling reported two issues outside this PR's five-file diff. No unrelated fixes were made.

  • No new manual web or native verification was performed for this merge. Results below predate this sync.

  • Passed: 109 tests across five focused suites covering tab focus, chart refresh gating, Escape cancellation, pre-mount cleanup, and fullscreen-under-RHP routing. The chart regression exercises the real tab-focus hook and navigation-state subscription, both with and without expense updates, and verifies refresh after a committed destination and genuine return to Home.

  • Passed: npm run typecheck, npm run lint-changed, npm run spell-changed, Storybook smoke test, git diff --check, and the commit hook's Oxfmt formatting. Staged code review reported no violations.

  • Incomplete: repository-wide lint exceeded 240 seconds; repository-wide Jest exceeded 300 seconds, with no failure entries before timeout. These are not reported as passing.

  • Tooling limits: the matrix's npm run prettier -- --log-level error cannot run because this checkout has no prettier script. The changed-files React Compiler check failed resolving origin/ because the base ref was empty; the explicit per-file check exited successfully.

  • Web verification blocked: dev NewDot returned an empty page and the test session remained suspended after one retry. Home, Back cancellation, Escape cancellation, and genuine tab-return chart requests could not be verified. This is not evidence of a product regression. Native verification remains outstanding.

AI Web Verification Evidence

Empty app page blocking verification

Contributor Branch

This draft is assigned to huult. The branch is upstream because Melvin does not have push access to the contributor's fork. To copy it to that fork:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-homeInsightsRhpFocus
git checkout -b claude-homeInsightsRhpFocus upstream/claude-homeInsightsRhpFocus
git push -u origin claude-homeInsightsRhpFocus

Screenshots/Videos

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

Co-authored-by: huult <huult@users.noreply.github.com>
@MelvinBot

MelvinBot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

Verified on dev NewDot web: Home > + > Create expense opens the RHP, and two Back cancellations return to Home. Missing workspace/expense fixtures prevent chart-refresh verification.

Empty Home after two Back cancellations

Step Status
1. Verify workspace and expense prerequisitesBlocked: Workspaces shows “No workspaces yet”; Home shows “No recent expenses”.
❌
2. Go to Home and scroll to InsightsHome was inspected and scrolled; no populated Insights chart was available.
❌
3. Open + > Create expenseThe RHP displayed Back, Manual, Scan, and Choose files.
Create expense right-hand pane
✅
4. Account B submits while Account A’s panel remains openNot tested: simultaneous accounts/sessions are unsupported by the available testing tools.
❌
5. Close the panel without refreshing InsightsBack returned to Home, but the no-refresh assertion could not be checked without a chart.
❌
6. Repeat Back cancellation without expense changesSecond cancellation returned to Home without creating expenses. Chart-refresh behavior remains unverified.
Empty Home after two Back cancellations
❌
7. Cancel using EscapeNot tested: the available web tool interface does not support Escape-key input.
❌
8. Submit an expense and genuinely return to HomeNot tested: missing workspace and populated-chart fixtures.
❌
9. Verify no JavaScript console errorsUnverified: console inspection is unavailable through the supported web tools.
❌

view run · view recording

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue. Try again. If it persists, check status.openai.com.

Run details

@MelvinBot

MelvinBot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ⚠️ partial

Verified navigation on standalone Android NewDot. Chart-refresh assertions remain unverified because the populated workspace-owner fixture is missing; concurrent-account testing is unsupported.

Create expense panel on Android

Step Status
1. Open Expensify Android appThe signed-in app displayed Home.
Android NewDot Home
✅
2. Go to Home and scroll to InsightsBlocked: Home showed “No recent expenses”; scrolling revealed no populated Insights chart. Workspace-owner prerequisites were not established.
Home empty state without a populated Insights chart
❌
3. Open + > Create expenseThe expense panel opened with Scan, Manual, and Back after dismissing a location prompt.
Create expense panel on Android
✅
4. Account B submits while Account A’s panel stays openBlocked: concurrent accounts/sessions are unsupported by the available tools.
❌
5. Close the panel without refreshing InsightsBack returned to Home. Chart behavior remains unverified without the populated chart and Account B submission.
❌
6. Repeat cancellation without another submissionCreate expense > Back returned to Home again without submitting. No-refresh behavior could not be proven without a chart.
❌
7. Leave Home and return to verify normal refreshInbox and subsequent Home selection succeeded; chart refresh remains unverified.
❌
8. Verify no JavaScript console errorsUnverified: session log capture was inactive and empty.
❌

view run · view recording

@huult

huult commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Could you please update the test steps and QA steps to follow the same format as the Action Performed section in #106873? Thanks!

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated Tests and QA Steps to match the issue’s Action Performed format: preconditions, numbered steps, and expected result. Added regression checks for cancellation, Escape, submission, and returning to Home.

Documentation only; no tests were rerun.


view run

@huult

huult commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot ready for review

@MelvinBot
MelvinBot marked this pull request as ready for review November 19, 2026 14:12
@MelvinBot
MelvinBot requested a review from a team as a code owner November 19, 2026 14:12
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Marked Prevent Home chart refresh when cancelling an expense panel as ready for review.


view run

@expensify-chore-bot
expensify-chore-bot Bot requested review from huult and removed request for a team November 19, 2026 14:12
@expensify-chore-bot

Copy link
Copy Markdown

@huult 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]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T14:48:45.664692Z 71e3897 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@expensify-chore-bot
expensify-chore-bot Bot requested review from dylanexpensify and removed request for a team November 19, 2026 14:13
@huult

huult commented Nov 19, 2026 •

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
  • I verified any copy / text that was added to the app 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 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
    • 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
    • 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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.2026-11-19.at.21.45.42.mov
Android: mWeb Chrome
Screen.Recording.2026-11-19.at.21.44.32.mov
iOS: HybridApp
Screen.Recording.2026-11-19.at.21.42.47.mov
iOS: mWeb Safari
Screen.Recording.2026-11-19.at.21.36.13.mov
MacOS: Chrome / Safari
Screen.Recording.2026-11-19.at.21.48.53.mov

@huult

huult commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@codex review

@huult

huult commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Please update both the test steps and QA steps to the following:

Precondition: Account A is the owner of a workspace with enough expenses to populate Home Insights. Account B is a member of the workspace submitting to Account A, so that expenses from B can alter Account A's Insights.

  1. Open Expensify on staging as Account A (use a narrow browser window when testing on web).
  2. Go to Home and scroll to the Insights chart.
  3. Open the RHP, for example, select + > Create expense.
  4. In a different session as Account B, submit an expense to the workspace.
  5. As Account A, close the RHP without creating or changing an expense.
  6. Verify that the chart does not refresh when the panel is closed.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated both Tests and QA Steps with your provided precondition and six steps, removing the additional regression checks.


view run

@dylanexpensify dylanexpensify 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.

Looks good from a product perspective 👍

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 71e3897bd1

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@huult

huult commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot I've verified #107382 (comment). Could you please check all the boxes in the Author Checklist? Thanks!

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Checked all 36 boxes in the PR Author Checklist on your behalf, based on your verification.


view run

@huult huult 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.

LGTM.

@melvin-bot
melvin-bot Bot requested a review from inimaga November 23, 2026 02:03
@huult

huult commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot could you sync with main?

Co-authored-by: huult <huult@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner November 23, 2026 02:28
@expensify-chore-bot
expensify-chore-bot Bot requested review from huult and removed request for a team November 23, 2026 02:28
@expensify-chore-bot

Copy link
Copy Markdown

@huult 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]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Synced with main and pushed merge commit c46a1e04e13. No conflicts.

10 focused tests passed; remaining checks hit tooling/dependency blockers documented in AI Tests.


view run

@huult

huult commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@inimaga This PR is ready for your review. Thanks!

@inimaga
inimaga merged commit 7b14bf4 into main Nov 23, 2026
45 checks passed
@inimaga
inimaga deleted the claude-homeInsightsRhpFocus branch November 23, 2026 11:15
@github-actions

Copy link
Copy Markdown
Contributor

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

@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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/inimaga in version: 9.5.53-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update needed — this PR fixes an unintended chart refresh when cancelling expense creation, restoring expected behavior without adding a workflow or making existing help instructions incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀

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

Bundle Size Analysis (Sentry):

1 similar comment
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀

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

Bundle Size Analysis (Sentry):

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants