diff --git a/client-web/src/modules/chats/presentation/components/GroupSettings.tsx b/client-web/src/modules/chats/presentation/components/GroupSettings.tsx index f6d3cba..6b7e496 100644 --- a/client-web/src/modules/chats/presentation/components/GroupSettings.tsx +++ b/client-web/src/modules/chats/presentation/components/GroupSettings.tsx @@ -76,9 +76,10 @@ export default function GroupSettings({ chat, onClose, onGoToMessage }: GroupSet const fileInputRef = useRef(null); const searchInputRef = useRef(null); + const getSearchedUserId = (u: UserPresence & { userId?: string }) => u.id || u.userId || ''; // Keep local state in sync with chat prop - useEffect(() => { + useEffect(() => { setGroupName(chat.name || ''); setGroupDesc(chat.description || ''); }, [chat.name, chat.description]); @@ -95,7 +96,10 @@ export default function GroupSettings({ chat, onClose, onGoToMessage }: GroupSet const results = await UserApi.searchUsers(searchQuery); // Filter out users already in the group const memberIds = new Set(chat.members.map((m) => m.user.id)); - setSearchResults(results.filter((u) => !memberIds.has(u.id))); + setSearchResults(results.filter((u) => { + const candidateId = getSearchedUserId(u as UserPresence & { userId?: string }); + return !!candidateId && !memberIds.has(candidateId); + })); } catch (e) { console.error(e); } finally { @@ -565,10 +569,13 @@ export default function GroupSettings({ chat, onClose, onGoToMessage }: GroupSet )} - {searchResults.map((u) => ( + {searchResults.map((u) => { + const candidateId = getSearchedUserId(u as UserPresence & { userId?: string }); + if (!candidateId) return null; + return ( - ))} + ); + })} {searchQuery.trim() && !isSearching && searchResults.length === 0 && (

{t('usersNotFound')}

)}