[Search v2.3] [Saved Searches] Fix duplicate saved searches#49243
Conversation
luacmartins
left a comment
There was a problem hiding this comment.
LGTM but do we have this consistency issue with other filters too? cc @Kicu
Yes with the expense type, just like in the video test of the related issue. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-09-18.at.12.47.03.PM.movAndroid: mWeb ChromeScreen.Recording.2024-09-18.at.12.43.43.PM.movScreen.Recording.2024-09-18.at.12.45.28.PM.moviOS: NativeScreen.Recording.2024-09-18.at.12.41.07.PM.moviOS: mWeb SafariScreen.Recording.2024-09-18.at.12.33.36.PM.movMacOS: Chrome / SafariScreen.Recording.2024-09-18.at.12.22.19.PM.movMacOS: DesktopScreen.Recording.2024-09-18.at.12.24.41.PM.mov |
Kicu
left a comment
There was a problem hiding this comment.
IMO it will be safer if we slightly rewrite the buildQueryStringFromFilterValues function to achieved a desirable effect
|
BUG The filter name resets when you save again. Screen.Recording.2024-09-16.at.1.03.12.PM.mov |
|
@allroundexperts I've fixed this @Kicu I've handled your comments Feel free to re-review, cc @luacmartins |
Kicu
left a comment
There was a problem hiding this comment.
Found a typo, this code looks much cleaner 👍
|
@allroundexperts can you please re-review? |
|
@lakchote Are we supposed to create a new search whenever a merchant is edited? I would just edit the existing one. Screen.Recording.2024-09-18.at.11.40.14.AM.mov |
Yes. |
|
Correct, we should create new searches if any of the values are changed |
|
✋ 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/luacmartins in version: 9.0.38-0 🚀
|
|
🚀 Deployed to production by https://github.com/grgia in version: 9.0.38-4 🚀
|
| const savedSearchKeys = Object.keys(savedSearches ?? {}); | ||
| if (savedSearches && savedSearchKeys.includes(String(queryJSON.hash))) { | ||
| // If the search is already saved, return early to prevent unnecessary API calls | ||
| Navigation.dismissModal(); |
There was a problem hiding this comment.
This caused a regression #53880. We should call applyFiltersAndNavigate here, so we only display the results as we don't need to save it.
| filtersString.push(amountFilter); | ||
|
|
||
| return filtersString.filter(Boolean).join(' '); | ||
| return filtersString.join(' ').trim(); |
There was a problem hiding this comment.
filtersString can be falsy, joining these falsy values by spaces will cause redundant spaces between the queries. Regression: #57696.

Details
When we open the search page there are no filters applied.
Then, when we open the advanced search filters, the filters
type: expense status: allare automatically applied.If we set a new filter, such as Merchant, the query string for the search will become
type: expense status: all merchant:test.Once we save the search, and make it the one currently selected, if we edit its filters however the type and status filters will be appended at the end of the array. As such the query string will become
merchant: test type: expense status: all.Since the query strings are different, if we save the search again, we'll have different hashes and as such duplicate saved searches.
This PR aims to make sure these filters are always applied at the beginning of the query string.
Fixed Issues
$ #49205
Tests
Offline tests
NA
QA Steps
Same as in tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so 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./** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop