Skip to content
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
Copy Markdown
Member

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