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)) {