Fix: Reports page auto-opening Approve tab when coming back online#77100
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
| const defaultMenuItem = getDefaultActionableSearchMenuItem(flattenedMenuItems); | ||
|
|
||
| if (!defaultMenuItem || similarSearchHash === defaultMenuItem.similarSearchHash) { | ||
| if (!defaultMenuItem || similarSearchHash) { |
There was a problem hiding this comment.
❌ Logic Bug: Falsy value handling (related to PERF rules)
The condition if (!defaultMenuItem || similarSearchHash) will fail when similarSearchHash is 0.
Since CONST.DEFAULT_NUMBER_ID = 0, and similarSearchHash can be 0 (a valid hash value), the truthy check will not work correctly. When similarSearchHash === 0, the condition evaluates to if (!defaultMenuItem || false), which won't prevent navigation even though a search is active.
Suggested fix:
if (!defaultMenuItem || similarSearchHash !== undefined) {
return;
}This correctly checks if similarSearchHash is defined (meaning any search is active, including one with hash value 0) rather than checking if it's truthy.
There was a problem hiding this comment.
What do you think of this comment, @nyomanjyotisa? I think it kind of makes sense, I just don't know exactly how similarSearchHash could be 0, in what scenario.
There was a problem hiding this comment.
Yeah agree, this suggestion makes sense as 0 could be treated as a valid hash. I think we should apply this as a defensive approach for that edge case. I've updated the PR!
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp77100_android_native.movAndroid: mWeb Chrome77100_android_web.moviOS: HybridApp77100_ios_native.moviOS: mWeb Safari77100_ios_web.movMacOS: Chrome / Safari77100_web_chrome.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.2.79-0 🚀
|
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.2.81-0 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.2.81-5 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.2.81-5 🚀
|
Explanation of Change
Prevent default navigation when user has already selected a tab by checking if
similarSearchHashis defined before navigating to the default actionable searchFixed Issues
$ #76622
PROPOSAL: #76622 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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-Native.mp4
Android: mWeb Chrome
Android-mWeb.Chrome.mp4
iOS: Native
iOS-Native.mp4
iOS: mWeb Safari
iOS-mWeb.Safari.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4