diff --git a/src/utils/communityUtils.ts b/src/utils/communityUtils.ts index a973a55..249faee 100644 --- a/src/utils/communityUtils.ts +++ b/src/utils/communityUtils.ts @@ -25,9 +25,15 @@ export async function isUserInCommunity(userJid: string, groupJids: Set) // Check if user is in this group's participants const participants = response.data?.participants || []; + console.log('Participants:', participants); + // Check both JID and phone number formats const userPhone = userJid.split('@')[0]; - if (participants.includes(userJid) || participants.some(p => p.startsWith(userPhone))) { + if (participants.some(p => { + // Handle both string and object participant formats + const participantJid = typeof p === 'string' ? p : p?.id; + return participantJid === userJid || participantJid?.startsWith?.(userPhone); + })) { return true; } }