Skip to content

Stop hidden report action popovers from re-rendering - #105946

Merged
roryabraham merged 4 commits into
Expensify:mainfrom
callstack-internal:perf/3218-hidden-popovers
Nov 6, 2026
Merged

roryabraham merged 4 commits into
Expensify:mainfrom
callstack-internal:perf/3218-hidden-popovers

Conversation

@sosek108

@sosek108 sosek108 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

PopoverReportActionContextMenu is mounted for the whole app, but it read about 20 Onyx values that only the delete confirmation needs, such as VISIBLE_REPORT_ACTIONS, TRANSACTION_VIOLATIONS, the self DM report, transactions and policies. Their keys came from refs read during render, so the hidden menu, its PopoverWithMeasuredContent and the hidden ConfirmModal re-rendered together with the report screen. Since manual memoization was removed in #104522, nothing stops those hidden popovers from rendering.

This PR moves the delete-only reads and the delete logic into a new useDeleteReportAction hook. Only the delete confirmation modal calls it, and that modal mounts only from the moment a delete is requested until it has finished hiding. The context menu shell no longer subscribes to Onyx at all. The comment delete still runs after the modal hides, so the row does not disappear under the closing modal. The hook hands that delete back to the menu through deleteAfterModalHide, because the menu owns the modal hide timing.

EmojiPicker read three refs during render (the anchor, the anchor dimensions and the active emoji), which kept it from compiling with React Compiler. These are now state, so the file compiles and its manual useCallback calls are gone.

A new UI test checks that the confirmation is not mounted until a delete is requested, that a comment is deleted only after the modal hides, and that cancel deletes nothing.

Results (iOS 17 Pro simulator, dev build, ABBA with 8 blocks against main):

  • Opening a report is 6 to 7% faster: ManualOpenReport went from 613 to 570 ms in an expense report and from 917 to 863 ms in the self DM.
  • Tab navigation is about 5% faster: ManualNavigateToReports went from 131 to 124 ms.
  • On report open, PopoverReportActionContextMenu and ConfirmModal went from 3 renders to 0, PopoverWithMeasuredContent from 5 to 2, and BaseModal/ReanimatedModal from 10 to 7.
  • EmojiPicker now compiles with React Compiler.

Fixed Issues

$ #105951
PROPOSAL:

Tests

  1. Open any chat and long-press (native) or right-click (web) a message. Verify the context menu opens next to the message with the reactions and all actions.
  2. Tap the add reaction button in the context menu. Verify the emoji picker opens, is positioned correctly, and closes on dismiss.
  3. Open the emoji picker from the composer emoji button. Pick an emoji and verify it is inserted and the picker closes.
  4. Open the context menu on your own comment and choose Delete. Verify the "Delete comment" confirmation appears. Tap Cancel and verify the modal closes and the comment is kept.
  5. Repeat step 4 and tap Delete. Verify the modal closes first and then the comment is removed.
  6. In a self DM, track an expense, open the context menu on it and delete it. Verify the expense is deleted.
  7. Open the context menu on an expense report preview and delete the report. Verify the report is deleted.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Delete your own comment through the context menu. Verify it is shown as pending deletion (struck through) after the modal closes.
  3. Go online and verify the comment is removed.

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

Screenshots/Videos

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

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/EmojiPicker/EmojiPicker.tsx 96.63% <100.00%> (+1.74%) ⬆️
...ort/ContextMenu/PopoverReportActionContextMenu.tsx 56.92% <97.05%> (+11.46%) ⬆️
.../inbox/report/ContextMenu/useDeleteReportAction.ts 87.50% <87.50%> (ø)
... and 187 files with indirect coverage changes

@sosek108
sosek108 marked this pull request as ready for review November 4, 2026 19:54
@sosek108
sosek108 requested review from a team as code owners November 4, 2026 19:54
@melvin-bot
melvin-bot Bot requested review from a team, heyjennahay and huult and removed request for a team November 4, 2026 19:54
@melvin-bot

melvin-bot Bot commented Nov 4, 2026

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]

@melvin-bot
melvin-bot Bot removed the request for review from a team November 4, 2026 19:54
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T20:13:47.594174Z 34e3367 Draft marked ready
ℹ️ 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.

@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: 34e3367a89

ℹ️ 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".

Comment on lines +365 to +368
if (isDeleteCommentConfirmModalVisible) {
return;
}

DeviceEventEmitter.emit(`deletedReportAction_${reportIDRef.current}`, reportAction?.reportActionID);
setIsDeleteCommentConfirmModalVisible(false);
}, [
report,
reportActions,
originalReportActions,
childReportActions,
childParentReportAction,
childReport,
selfDMReport,
iouReport,
iouReportTransactions,
chatReport,
duplicateTransactions,
duplicateTransactionViolations,
isReportArchived,
isChatIOUReportArchived,
allTransactionViolations,
currentUserAccountID,
delegateAccountID,
deleteTransactions,
currentSearchHash,
email,
reportTransactions,
bankAccountList,
isOriginalReportArchived,
isOffline,
visibleReportActionsData,
iouTransaction,
iouOriginalTransaction,
iouPolicy,
getCurrencyDecimals,
]);
setDeleteModalTarget(null);

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 Preserve a delete modal reopened during its exit

On Android, if a second delete is requested while the first confirmation's exit animation is still running, this closure still contains false: BaseModal explicitly documents that Reanimated's hide callback comes from the exit-animation snapshot (src/components/Modal/BaseModal.tsx:125-127), and that snapshot invokes the onModalHide supplied by the closed render. The check therefore falls through to setDeleteModalTarget(null) and removes the newly reopened confirmation; read the current visibility from a ref (or otherwise from current state) before clearing the target.

Useful? React with 👍 / 👎.

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.

@sosek108 could you check this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the codex comment is right, i've implemented it adding a ref to keep the state in sync

@huult

huult commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Reviewing

@huult

huult commented Nov 5, 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-05.at.11.49.12.mov
Android: mWeb Chrome
Screen.Recording.2026-11-05.at.11.46.40.mov
iOS: HybridApp
Screen.Recording.2026-11-05.at.11.40.06.mov
iOS: mWeb Safari
Screen.Recording.2026-11-05.at.11.41.37.mov
MacOS: Chrome / Safari
Screen.Recording.2026-11-05.at.11.37.45.mp4

@huult

huult commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

iOS: renders on report open

React DevTools profiler, opening "Expense Report 2026-02-26" from the Inbox. 1 warmup + 3 profiled opens per branch, identical in all 3 opens.

Component (per open) main PR Description
ConfirmModal 3 0 3 → 0
PopoverWithMeasuredContent 5 2 5 → 2
PopoverReportActionContextMenu 3 1 3 → 0
BaseModal / ReanimatedModal 14 / 14 11 / 11 10 → 7

iOS: ManualOpenReport timing (ms)

ABBA (PR, main, main, PR), 1 warmup + 8 runs per block.

Block Samples Mean Median
PR-1 611 636 603 609 632 691 647 850 660 634
main-1 638 637 704 641 659 693 653 779 676 656
main-2 638 652 615 710 639 753 691 787 686 672
PR-2 598 646 639 630 682 707 656 702 658 651
Branch n Mean Median SD Min Max
main 16 681 656 54 615 787
PR 16 659 642 61 598 850

PR is 22 ms (3.2%) faster on the mean and 14 ms (2.1%) on the median. Welch t = 1.07 and Mann-Whitney z = 1.62, so the difference is not statistically significant with 16 samples per branch, and it is lower than the 6-7% in the description.

@sosek108

sosek108 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@huult I've responded to Codex comment. You can continue

@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 roryabraham November 5, 2026 14:36
@roryabraham
roryabraham merged commit 0cb395c into Expensify:main Nov 6, 2026
38 of 40 checks passed
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Nov 6, 2026

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

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@OSBotify OSBotify mentioned this pull request Nov 7, 2026
85 tasks done
@OSBotify

OSBotify commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.34-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR optimizes rendering while preserving existing deletion and emoji workflows, without introducing a new feature or making any existing article sentence incorrect.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed — this PR only optimizes rendering and refactors existing deletion and emoji-picker workflows, without adding new interactions, screens, user-property values, or sensitive content.


view run

@OSBotify

OSBotify commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.34-1 🚀

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants