Fix "same search query appears twice in Recent searches"#51314
Conversation
|
Let's move this PR forward @rayane-djouah 🙏 |
rayane-d
left a comment
There was a problem hiding this comment.
@SzymczakJ I think we need to exclude policyID from recentSearchHash also because searches that differ only by policyID appear multiple times in Recent searches:
WDYT?
| orderedQuery += ` ${buildFilterValuesString(key, sortedFilterValues ?? [])}`; | ||
| orderedQuery += `${buildFilterValuesString(key, sortedFilterValues ?? [])}`; | ||
| }); | ||
| const recentSearchHash = UserUtils.hashText(orderedQuery, 2 ** 32); |
There was a problem hiding this comment.
Thinking more about it. What if a user explicitly types policyID:X sortOrder:asc? Should we instead just be hashing the input string instead of parts of the AST? That'd ensure anything the user types differently would be a new recent search
There was a problem hiding this comment.
We cannot hash string input. My argument: when user types policyID:X sortOrder:asc and sortOrder:asc policyID:X, we will get different hashes even though the query results will be the same.
I think we should exclude policyID like @rayane-djouah said. It may create some confusion when user types policy:X into query, but:
- We have a policy switcher, which is dedicated way of changing policyID, so typing policyID into SearchRouter query is the worst way to change your policyID
- We don't even autocomplete policyID key, so how will a user know that such option exists.
- It's unlikely that a real user will type something like policyID:31294891892741873, without the help of autocomplete.
What's more if user selects recentSearch with not the policyID he wanted, he can easily switch it on SearchResults page with policy switcher and it's not such a big problem(just like he switches sortOrder or sortBy). WDYT @rayane-djouah @luacmartins
There was a problem hiding this comment.
I think we can go with your current solution for now, but:
when user types policyID:X sortOrder:asc and sortOrder:asc policyID:X
TBH I'd be ok to show both of these as different recent searches, even though they are the same search at the end of the day. My argument is that the user explicitly typed both of those, so they'd probably expect to see both in the recent search area.
We don't even autocomplete policyID key, so how will a user know that such option exists.
I think we should introduce policyID autocomplete. Maybe we need a new workspace: filter for that though, so the autocomplete shows the policy name instead of ID.
cc @JmillsExpensify @trjExpensify for your thoughts.
@SzymczakJ backend PR is in review |
I agree with Carlos on this comment. |
For this one, we should be careful as I'm imagining that we'd support the ability to search on multiple policies at once right? If so, then we need to introduce a way for the front-end to do the same in the workspace switcher. |
Yes. The syntax already supports this, so technically if users typed |
luacmartins
left a comment
There was a problem hiding this comment.
@SzymczakJ so let's update the hash to be on the input query so we always show whatever users type, regardless of it being the same query as a previous one (if the only difference is the order of filters)
|
But using inputQuery as a hash input will not fix this bug #51044! |
|
Yea, that's a good point, but I think it would solve the bug unless users manually type |
Thats actually the main root cause of the bug, what's more there will be also a bug when user changes sortOrder on search results page, which is highly probable. I would actually go with the current solution where:
Like you said later we could split this into two cases:
|
|
I'm ok using the current logic as a stepping stone, but I think ultimately we're aiming for the behavior below, so we'll need to work on a follow up for that.
|
|
I agree. So we need to store on BE what user typed into the search router and return it in recentSearches exactly as it was, but only in case, when it was made by SearchRouter |
|
Correct. We currently store the |
|
@rayane-djouah let's resume reviews on this PR |
|
FYI I'll OOO on Friday and Monday. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-11-02.at.11.29.37.PM.movAndroid: mWeb ChromeScreen.Recording.2024-11-02.at.11.26.38.PM.moviOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-11-02.at.23.25.08.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-11-02.at.23.22.50.mp4MacOS: Chrome / SafariScreen.Recording.2024-11-02.at.11.13.05.PM.movMacOS: DesktopScreen.Recording.2024-11-02.at.11.02.30.PM.mov |
|
Let's add these QA Steps:
|
src/libs/SearchQueryUtils.ts
Outdated
| } | ||
| orderedQuery += `${CONST.SEARCH.SYNTAX_ROOT_KEYS.TYPE}:${query.type}`; | ||
| orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS}:${query.status}`; | ||
| orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY}:${query.sortBy}`; |
There was a problem hiding this comment.
| orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY}:${query.sortBy}`; |
we're incorrectly including sortBy and sortOrder in orderedQuery here for recentSearchHash and then adding them again at the end of orderedQuery for primaryHash
we need to remove these two lines
There was a problem hiding this comment.
Whoops, that's probably my mistake when merging main 🙇
|
@289Adam289 Could you please address the above comment, as @SzymczakJ will be OOO according to this comment? Thank you! |
|
Hi! I was also OOO on Friday. @SzymczakJ will be back tomorrow and I think it would be best to leave addressing comments to him. |
|
I've added the tests steps and fixed bug you mentioned @rayane-djouah |
|
✋ 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.58-0 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.0.58-2 🚀
|




Details
Fixed Issues
$ #51044
PROPOSAL:
Tests
Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.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 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.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop