Skip to content

Commit

Permalink
Merge pull request #23982 from dukenv0307/fix/23503
Browse files Browse the repository at this point in the history
New group can't search an email if it's a substring of a selected email
  • Loading branch information
tgolen authored Aug 7, 2023
2 parents 8639fb6 + 3f3fd25 commit 242bfe7
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,23 @@ function NewChatPage(props) {
}
}

// Filtering out selected users from the search results
const filterText = _.reduce(selectedOptions, (str, {login}) => `${str} ${login}`, '');
const recentReportsWithoutSelected = _.filter(filteredRecentReports, ({login}) => !filterText.includes(login));
const personalDetailsWithoutSelected = _.filter(filteredPersonalDetails, ({login}) => !filterText.includes(login));
const hasUnselectedUserToInvite = filteredUserToInvite && !filterText.includes(filteredUserToInvite.login);

sectionsList.push({
title: props.translate('common.recents'),
data: recentReportsWithoutSelected,
shouldShow: !_.isEmpty(recentReportsWithoutSelected),
data: filteredRecentReports,
shouldShow: !_.isEmpty(filteredRecentReports),
indexOffset,
});
indexOffset += recentReportsWithoutSelected.length;
indexOffset += filteredRecentReports.length;

sectionsList.push({
title: props.translate('common.contacts'),
data: personalDetailsWithoutSelected,
shouldShow: !_.isEmpty(personalDetailsWithoutSelected),
data: filteredPersonalDetails,
shouldShow: !_.isEmpty(filteredPersonalDetails),
indexOffset,
});
indexOffset += personalDetailsWithoutSelected.length;
indexOffset += filteredPersonalDetails.length;

if (hasUnselectedUserToInvite) {
if (filteredUserToInvite) {
sectionsList.push({
title: undefined,
data: [filteredUserToInvite],
Expand Down Expand Up @@ -130,7 +124,14 @@ function NewChatPage(props) {
newSelectedOptions = [...selectedOptions, option];
}

const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getNewChatOptions(props.reports, props.personalDetails, props.betas, searchTerm, [], excludedGroupEmails);
const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getNewChatOptions(
props.reports,
props.personalDetails,
props.betas,
searchTerm,
newSelectedOptions,
excludedGroupEmails,
);

setSelectedOptions(newSelectedOptions);
setFilteredRecentReports(recentReports);
Expand Down Expand Up @@ -169,7 +170,7 @@ function NewChatPage(props) {
props.personalDetails,
props.betas,
searchTerm,
[],
selectedOptions,
props.isGroupChat ? excludedGroupEmails : [],
);
setFilteredRecentReports(recentReports);
Expand Down

0 comments on commit 242bfe7

Please sign in to comment.