Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New group can't search an email if it's a substring of a selected email #23982

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Comment on lines -172 to +173
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused a regression #26072. We used to pass an empty array so we get a non-empty userToInvite. The userToInvite was used in getHeaderMessage not to return unwanted error messages.

props.isGroupChat ? excludedGroupEmails : [],
);
setFilteredRecentReports(recentReports);
Expand Down