From d65ee7a157204ab39ad54cb632d5721049388893 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Wed, 30 Jun 2021 21:40:20 -0400 Subject: [PATCH 1/6] Don't search for participants of a default room --- src/libs/OptionsListUtils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 66c1d76e024e..569f8250430e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -143,7 +143,11 @@ function getSearchText(report, personalDetailList) { if (report) { searchTerms.push(...report.reportName); searchTerms.push(...report.reportName.split(',').map(name => name.trim())); - searchTerms.push(...report.participants); + + // Do not include participants as search terms for default rooms + if (!isDefaultRoom(report)) { + searchTerms.push(...report.participants); + } // Add policy name as a search term for default rooms if (isDefaultRoom(report) && policies[report.policyID]) { From 7c9370e6454dac662cecb7a7a6754f4e91459bc9 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Thu, 1 Jul 2021 19:23:10 -0400 Subject: [PATCH 2/6] Exclude all default rooms from new chat and new group searches --- src/libs/OptionsListUtils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 569f8250430e..ebe2bb6cf15f 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -265,6 +265,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { selectedOptions = [], maxRecentReportsToShow = 0, excludeConcierge = false, + excludeDefaultRooms = false, includeMultipleParticipantReports = false, includePersonalDetails = false, includeRecentReports = false, @@ -307,7 +308,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { return; } - if (isDefaultRoom(report) && !Permissions.canUseDefaultRooms(betas)) { + if (isDefaultRoom(report) && (!Permissions.canUseDefaultRooms(betas) || excludeDefaultRooms)) { return; } @@ -479,6 +480,7 @@ function getNewChatOptions( return getOptions(reports, personalDetails, {}, 0, { betas, searchValue, + excludeDefaultRooms: true, includePersonalDetails: true, includeRecentReports: true, maxRecentReportsToShow: 5, @@ -540,6 +542,7 @@ function getNewGroupOptions( betas, searchValue, selectedOptions, + excludeDefaultRooms: true, includeRecentReports: true, includePersonalDetails: true, includeMultipleParticipantReports: false, From bf8378492ca924e4686a87e6b74ea0e62b73fa9c Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 2 Jul 2021 14:32:53 -0400 Subject: [PATCH 3/6] Ensure participants aren't search criteria for default rooms --- src/libs/OptionsListUtils.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index ebe2bb6cf15f..24e4d4e306c4 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -127,30 +127,32 @@ function getParticipantNames(personalDetailList) { } /** - * Returns a string with all relevant search terms + * Returns a string with all relevant search terms. + * Default should be serachable by policy/domain name but not by participants. * * @param {Object} report * @param {Array} personalDetailList + * @param {Boolean} isDefaultChatRoom * @return {String} */ -function getSearchText(report, personalDetailList) { +function getSearchText(report, personalDetailList, isDefaultChatRoom) { const searchTerms = []; - _.each(personalDetailList, (personalDetail) => { - searchTerms.push(personalDetail.displayName); - searchTerms.push(personalDetail.login); - }); + if (!isDefaultChatRoom) { + _.each(personalDetailList, (personalDetail) => { + searchTerms.push(personalDetail.displayName); + searchTerms.push(personalDetail.login); + }); + } if (report) { searchTerms.push(...report.reportName); searchTerms.push(...report.reportName.split(',').map(name => name.trim())); - // Do not include participants as search terms for default rooms - if (!isDefaultRoom(report)) { + if (!isDefaultChatRoom) { searchTerms.push(...report.participants); } - // Add policy name as a search term for default rooms - if (isDefaultRoom(report) && policies[report.policyID]) { + if (isDefaultChatRoom && policies[report.policyID]) { searchTerms.push(...policies[report.policyID].name); } } @@ -221,7 +223,7 @@ function createOption(personalDetailList, report, draftComments, { isUnread: report ? report.unreadActionCount > 0 : null, hasDraftComment, keyForList: report ? String(report.reportID) : personalDetail.login, - searchText: getSearchText(report, personalDetailList), + searchText: getSearchText(report, personalDetailList, isDefaultChatRoom), isPinned: lodashGet(report, 'isPinned', false), hasOutstandingIOU, iouReportID: lodashGet(report, 'iouReportID'), From debd22dd30a402d34af6d478a8888e7d0b69aa81 Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 2 Jul 2021 16:05:25 -0400 Subject: [PATCH 4/6] Fix policy name searching --- src/libs/OptionsListUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 24e4d4e306c4..5fecbf2997a2 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -128,7 +128,7 @@ function getParticipantNames(personalDetailList) { /** * Returns a string with all relevant search terms. - * Default should be serachable by policy/domain name but not by participants. + * Default should be serachable by policy name but not by participants. * * @param {Object} report * @param {Array} personalDetailList @@ -153,7 +153,9 @@ function getSearchText(report, personalDetailList, isDefaultChatRoom) { } if (isDefaultChatRoom && policies[report.policyID]) { - searchTerms.push(...policies[report.policyID].name); + const policyName = policies[report.policyID].name; + searchTerms.push(...policyName); + searchTerms.push(...policyName.split(',').map(name => name.trim())); } } From 7fd2f103b2148b9778a21076a0b910bee65f691c Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 2 Jul 2021 16:16:55 -0400 Subject: [PATCH 5/6] Prioritize default rooms in searches --- src/libs/OptionsListUtils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 5fecbf2997a2..231704096d33 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -274,6 +274,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { includePersonalDetails = false, includeRecentReports = false, prioritizePinnedReports = false, + prioritizeDefaultChatRooms = false, sortByLastMessageTimestamp = false, searchValue = '', showChatPreviewLine = false, @@ -390,6 +391,12 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { recentReportOptions = sortedPinnedReports.concat(recentReportOptions); } + // If we are prioritizing the default rooms, split them out and put them first + if (prioritizeDefaultChatRooms) { + const reportsSplitByDefaultChatRoom = _.partition(recentReportOptions, option => option.isDefaultChatRoom); + recentReportOptions = reportsSplitByDefaultChatRoom[0].concat(reportsSplitByDefaultChatRoom[1]); + } + if (includePersonalDetails) { // Next loop over all personal details removing any that are selectedUsers or recentChats _.each(allPersonalDetailsOptions, (personalDetailOption) => { @@ -456,6 +463,7 @@ function getSearchOptions( includeMultipleParticipantReports: true, maxRecentReportsToShow: 0, // Unlimited prioritizePinnedReports: false, + prioritizeDefaultChatRooms: true, showChatPreviewLine: true, showReportsWithNoComments: true, includePersonalDetails: true, From bddae03e18948defdd7a6ebe1cceb8f396f2a43a Mon Sep 17 00:00:00 2001 From: Amal Nazeem Date: Fri, 2 Jul 2021 16:45:37 -0400 Subject: [PATCH 6/6] Prioritize default rooms in search only when we start searching --- src/libs/OptionsListUtils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 231704096d33..03d90e252782 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -274,7 +274,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { includePersonalDetails = false, includeRecentReports = false, prioritizePinnedReports = false, - prioritizeDefaultChatRooms = false, + prioritizeDefaultRoomsInSearch = false, sortByLastMessageTimestamp = false, searchValue = '', showChatPreviewLine = false, @@ -391,8 +391,8 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, { recentReportOptions = sortedPinnedReports.concat(recentReportOptions); } - // If we are prioritizing the default rooms, split them out and put them first - if (prioritizeDefaultChatRooms) { + // If we are prioritizing default rooms in search, do it only once we started something + if (prioritizeDefaultRoomsInSearch && searchValue !== '') { const reportsSplitByDefaultChatRoom = _.partition(recentReportOptions, option => option.isDefaultChatRoom); recentReportOptions = reportsSplitByDefaultChatRoom[0].concat(reportsSplitByDefaultChatRoom[1]); } @@ -463,7 +463,7 @@ function getSearchOptions( includeMultipleParticipantReports: true, maxRecentReportsToShow: 0, // Unlimited prioritizePinnedReports: false, - prioritizeDefaultChatRooms: true, + prioritizeDefaultRoomsInSearch: true, showChatPreviewLine: true, showReportsWithNoComments: true, includePersonalDetails: true,