Optimize ShareTab component by implementing same optimizations as in SearchAutocompleteList#66965
Conversation
|
@kacper-mikolajczak Made it ready for a review, though can you sync with main and also lets wait for the pr to hit staging and not be reverted 😄 |
|
PR prepared for review ✅ @mountiny |
|
@roryabraham Seems like this PR could also be related to changes there: #67073 (review) |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid-rec-15.webmiOS: HybridAppsimulator-screen-recording-iphone-15-pro-2025-08-05-at-164535_ujoDXw9C.mp4 |
|
Lets remove 9&10 from tests |
|
Yeah, there's definitely overlap between this PR and #67073 (review). Let's put both on HOLD until @sosek108 is back |
|
@roryabraham I think we do not have to wait since @kacper-mikolajczak has taken over his work intentionally when @sosek108 is ooo |
|
@mountiny see convo in the other PR |
|
Ah I see, thanks! Makes sense, would love to get the PR size to much more manageable state! |
|
It's not the size that really tripped me up - but the lack of screenshots and benchmarks. The size made the code harder to review, but wasn't really a blocker |
|
Yep, all those points are valid, we still expect even from the expert contributors @kacper-mikolajczak @sosek108 to complete the checklist fully with recordings too. Exceptions can be made. For performance PRs, always make sure to link the results, too, please. Usually you have those in the proposal already but in case of this pr, it changes up a loot since the proposal so fresh measurements are welcomed |
|
I think that we can unhold this PR as I am back. In previous comment I've posted benchmark for ShareTab that shows visible upgrade on component load time. |
|
Is the ShareTab not available on Android? Now I am not sure |
It's available |
|
@sosek108 Can you please include the android testing videos too? Thanks! Keep in mind to include it for all platforms where applicable on all PRs unless otherwise specified |
|
@sosek108 if this is ready for review, feel free to remove |
|
I see you mentioned it's ready to come off hold, so I'll just go for it |
|
Here is video for Android. Right is new version:/ android.mp4 |
| * @returns True if all search terms are found in the search text | ||
| */ | ||
| function doSearchTermsMatch(searchTerms: string[], searchText: string): boolean { | ||
| return searchTerms.length > 0 ? searchTerms.every((term) => searchText.includes(term)) : true; |
There was a problem hiding this comment.
NAB but this ternary is unnecessary. You can just do this:
| return searchTerms.length > 0 ? searchTerms.every((term) => searchText.includes(term)) : true; | |
| return searchTerms.every((term) => searchText.includes(term)); |
If searchTerms is an empty array, it will return true
There was a problem hiding this comment.
and in that case, I think you could just remove the named doSearchTermsMatch function and inline that simple statement 🤷🏼
There was a problem hiding this comment.
Yeah that would be a good clean up but NAB
There was a problem hiding this comment.
Thanks, good catch!
mountiny
left a comment
There was a problem hiding this comment.
Looks good to me, just some follow up questions
| * @returns True if all search terms are found in the search text | ||
| */ | ||
| function doSearchTermsMatch(searchTerms: string[], searchText: string): boolean { | ||
| return searchTerms.length > 0 ? searchTerms.every((term) => searchText.includes(term)) : true; |
There was a problem hiding this comment.
Yeah that would be a good clean up but NAB
| searchText += report.subtitle ?? ''; | ||
| } else if (report.isPolicyExpenseChat) { | ||
| searchText += `${report.subtitle ?? ''}${report.policyName ?? ''}`; | ||
| searchText += `${report.subtitle ?? ''}${report.item.policyName ?? ''}`; |
There was a problem hiding this comment.
I find it confusing why we sometimes access it directly and in this case through item
There was a problem hiding this comment.
Probably autofill mistake. Fixed
|
We have conflicts here now, so please address the small cleanup items when you resolve conflicts then we can merge this. Thanks! |
|
I've resolved merge conflict and applied cleaning fixes pointed out by @roryabraham and @mountiny (thanks for them!). Now I see that |
mountiny
left a comment
There was a problem hiding this comment.
Seems like there were few things leftover
|
@mountiny I've removed one leftover comment and answered your other comments. All checks are passing now 🎉. |
mountiny
left a comment
There was a problem hiding this comment.
Rory already approved and now there are no checks failing or no conflicts so I will merge this
|
✋ 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/mountiny in version: 9.1.91-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.1.92-5 🚀
|
Explanation of Change
This change continues the SearchAutocompleteList performance optimization (#65810) by applying the same pattern to the ShareTab component. Instead of using a two-step process (get all options, then filter), it moves the filtering logic directly into the getSearchOptions call with search parameters (textInputValue, limit of 20, filtering enabled). This eliminates the useFastSearchFromOptions hook dependency and reduces computational overhead by avoiding intermediate data structure creation. The optimization maintains all existing functionality while providing the same performance benefits as the SearchAutocompleteList component.
Fixed Issues
$ #66615
PROPOSAL: #66615
Tests
ShareExpensifyappRecent chatsare presented in right orderalfa)alfa beta)Offline tests
N/A
QA Steps
ShareExpensifyappRecent chatsare presented in right orderalfa)alfa beta)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))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.mp4
Android: mWeb Chrome
iOS: Native
Moj.film.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop