From 765ee984acd9bc5a798b7ccc6da61c54c637e643 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Sat, 1 Jun 2024 00:29:11 +0300 Subject: [PATCH] Fix user autocomplete not showing users not in channel (#7980) (#7985) --- app/components/autocomplete/at_mention/at_mention.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/autocomplete/at_mention/at_mention.tsx b/app/components/autocomplete/at_mention/at_mention.tsx index 3abd98a71..2fb8b2766 100644 --- a/app/components/autocomplete/at_mention/at_mention.tsx +++ b/app/components/autocomplete/at_mention/at_mention.tsx @@ -298,8 +298,14 @@ const AtMention = ({ if (outOfChannel?.length) { const outChannelMemberIds = outOfChannel.map((e) => e.id); + + // This only get us the users we have on the database. + // We need to append those users from which we don't have + // information at the end of the list. const outSortedMembers = await getUsersFromDMSorted(database, outChannelMemberIds); - sortedMembers.push(...outSortedMembers); + const idSet = new Set(outSortedMembers.map((v) => v.id)); + const outRest = outOfChannel.filter((v) => !idSet.has(v.id)); + sortedMembers.push(...outSortedMembers, ...outRest); } if (hasTrailingSpaces(term)) {