[No QA] Add tests for SearchMoneyRequestReportPage dismiss-on-removal logic#89247
Conversation
|
@abzokhattab 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] |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@abzokhattab can you please add a checklist? |
|
Yes let me check the pr |
There was a problem hiding this comment.
Pull request overview
Extracts the “dismiss modal when the currently-focused money request report disappears” logic from SearchMoneyRequestReportPage into a dedicated hook so the behavior can be unit-tested and regressions (e.g. #89150 / #89177) are prevented.
Changes:
- Added
useDismissOnReportRemovalhook to encapsulate the removal-detection + route-change guard logic. - Updated
SearchMoneyRequestReportPageto use the new hook instead of the inline effect. - Added a new unit test suite with 7 cases covering deletion/removal, focus conditions, route changes, and a regression/navigation scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/unit/hooks/useDismissOnReportRemoval.test.ts | Adds unit tests covering modal-dismiss behavior and route-change regressions. |
| src/pages/Search/SearchMoneyRequestReportPage.tsx | Replaces inline “dismiss on report removal” effect with the extracted hook. |
| src/hooks/useDismissOnReportRemoval.ts | Introduces a new hook implementing the dismissal/removal detection logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function useDismissOnReportRemoval(reportIDFromRoute: string | undefined) { | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportIDFromRoute}`); | ||
| const prevReport = usePrevious(report); |
There was a problem hiding this comment.
The hook name useDismissOnReportRemoval is generic, but the implementation only dismisses for money request reports (isMoneyRequestReport(prevReport)). To avoid accidental reuse with incorrect expectations, consider renaming it to reflect the money-request constraint (or making the behavior configurable via a predicate/flag).
|
@MelvinBot review |
PR ReviewClean extraction — the hook logic is correct and the 7 test cases are well-chosen, especially the regression scenarios for arrow navigation. Issues1. Duplicate Onyx subscription (minor) The hook subscribes to 2. Hook name could be more specific (nit)
Looks good
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
left comments & updated hook name |
|
Conflicts |
…uest-report-tests # Conflicts: # Mobile-Expensify
|
resolved ✅ |
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.66-0 🚀
|
|
This PR is a pure internal code refactoring — it extracts a dismiss-on-removal effect into a dedicated hook ( No help site documentation changes are required. |
Explanation of Change
Follow-up to #89150 per @mountiny's review request (#89150 (review)).
Extracts the removal-detection effect from
SearchMoneyRequestReportPageinto a dedicated hookuseDismissOnReportRemovalso it can be unit-tested in isolation. The hook fetches report data internally viauseOnyx— no behavioral change, same logic and route-change guard as before.Adds 7 unit test cases covering:
Fixed Issues
$ #89177
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari