Repository navigation
Move the logic of excluding contacts of DMs already included in reports to filterOptions - #50426
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: Native0-android.mp4MacOS: Chrome / SafariMacOS: Desktop0-desktop.mp4 |
eh2077
left a comment
There was a problem hiding this comment.
Tested various cases and all look good. Just a comment worrying about possible performance downgrade.
| if (maxRecentReportsToShow > 0 && recentReports.length > maxRecentReportsToShow) { | ||
| recentReports.splice(maxRecentReportsToShow); | ||
| } | ||
| const filteredPersonalDetails = filteredPersonalDetailsOfRecentReports(recentReports, personalDetails); |
There was a problem hiding this comment.
Is there a use case when maxRecentReportsToShow = 0 and recentReports is a long list? If so, then it seems there will be a performance downgrade here. Wdyt?
There was a problem hiding this comment.
It will but that might not be significant.
We iterate over all recentReports here for each search word.
App/src/libs/OptionsListUtils.ts
Lines 2520 to 2542 in 9d86f30
We iterate over the recentReports once more for this function filteredPersonalDetailsOfRecentReports.
Since, we pass searchTerm only to this function filterOptions and not getOptions, we need to do this exclusion of contacts only here.
MonilBhavsar
left a comment
There was a problem hiding this comment.
I am going to review it on Monday.
Should we add lint rule to prevent wrong usage of filterOptions() as we discussed?
I checked the We have two other options.
if (options && options.reports && options.reports.length !== 0 && searchInputValue) {
console.error('getOptions: Do not provide searchInputValue when options.reports is not empty. Use the performant filterOptions to filter with searchInputValue.');
}
|
This sounds good, plus we can add a comment 👍 |
|
Yeah, I also agree - modifying types to achieve it sounds more viable 👍 |
|
Thanks! Let's do it 👍 |
|
I have not found a way to enforce the constraint in Here is the branch with some files changed. When we pass a search term in cases with reports or personal details (in the In cases where they are not passed, we can pass a search term, and TypeScript does not complain (as seen in enforceEmptySearchTerm.mp4This type modification can also make the usage of I think we should handle that in a separate PR so that if we make any mistakes, we can revert it easily. |
|
@c3024 Thanks for the update! Is it possible to achieve what we want through function overloads? See https://www.typescriptlang.org/docs/handbook/2/functions.html#function-overloads |
|
I did try with functional overloads with |
@c3024 Hmm, I think it's better to do this in this PR together because here we have good intention and willingness - prevent wrong usage and get cleaner codebase. |
|
There ya go! 🤞 |
eh2077
left a comment
There was a problem hiding this comment.
looks good, just minor comments
| (canUseP2PDistanceRequests || iouRequestType !== CONST.IOU.REQUEST_TYPE.DISTANCE) && !isCategorizeOrShareAction, | ||
| false, | ||
| false, | ||
| 0, |
There was a problem hiding this comment.
maxRecentReportsToShow: 0 is missing
There was a problem hiding this comment.
Done.
Screen.Recording.2024-10-17.at.9.04.48.PM.mov
MonilBhavsar
left a comment
There was a problem hiding this comment.
Thanks for TS cleanup. Looks good!
|
Thanks for the comments. Updated with these suggestions. I added a couple of comments in the last commit explaining why we are enforcing the types. Please have a look! |
|
Thank you for comments! |
|
✋ 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/MonilBhavsar in version: 9.0.51-1 🚀
|
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.0.51-4 🚀
|
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.0.51-4 🚀
|































Details
Presently,
getOptionsexcludes the contacts of DM reports included inrecentReports. These are reduced to 5 recent reports in the participant selection page of "Submit Expense" flow if we pass amaxRecentReportsToShowtofilterOptions. Because the contacts of these DM reports are excluded already ingetOptions, these do not appear in the "Contacts" section. The logic of exclusion of Contacts for reports added in recent reports is moved fromgetOptionstofilterOptionsto fix this issue.Fixed Issues
$ #48114
PROPOSAL: #48114 (comment)
Tests
[Pre-requisite]: Login an account with more than 5 (say 10 DM) reports.
Test 1:
-- there are 5 recent reports in "Recents" section
-- all contacts of DMs not included in the "Recents" section are included in the "Contacts" section
-- contact of any DM shown in "Recents" section is not shown in "Contacts" section
-- there are 5 recent reports matching with the search term in "Recents" section
-- all contacts (matching with the search term) of DMs not included in the "Recents" section are included in the "Contacts" section
-- contact of any DM report matching with the search term shown in "Recents" section is not shown in "Contacts" section
Test 2:
Test 3:
Test 4:
Offline tests
[Pre-requisite]: Login an account with more than 5 (say 10 DM) reports.
Test 1:
-- there are 5 recent reports in "Recents" section
-- all contacts of DMs not included in the "Recents" section are included in the "Contacts" section
-- contact of any DM shown in "Recents" section is not shown in "Contacts" section
-- there are 5 recent reports matching with the search term in "Recents" section
-- all contacts (matching with the search term) of DMs not included in the "Recents" section are included in the "Contacts" section
-- contact of any DM report matching with the search term shown in "Recents" section is not shown in "Contacts" section
Test 2:
Test 3:
Test 4:
QA Steps
[Pre-requisite]: Login an account with more than 5 (say 10 DM) reports.
Test 1:
-- there are 5 recent reports in "Recents" section
-- all contacts of DMs not included in the "Recents" section are included in the "Contacts" section
-- contact of any DM shown in "Recents" section is not shown in "Contacts" section
-- there are 5 recent reports matching with the search term in "Recents" section
-- all contacts (matching with the search term) of DMs not included in the "Recents" section are included in the "Contacts" section
-- contact of any DM report matching with the search term shown in "Recents" section is not shown in "Contacts" section
Test 2:
Test 3:
Test 4:
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.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
filterAndroid1.mp4
filterAndroid2.mp4
filterAndroid3.mp4
Android: mWeb Chrome
filterAndroidmWeb.mp4
iOS: Native
filteriOS.mp4
iOS: mWeb Safari
filteriOSmWeb.mp4
MacOS: Chrome / Safari
filterChrome.mp4
MacOS: Desktop
filterDesktop.mp4