diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -1051,8 +1051,12 @@ return !!memberInfo.permissions[threadPermissions.CHANGE_ROLE]?.value; } +function roleIsDefaultRole(roleInfo: ?RoleInfo): boolean { + return !!(roleInfo && roleInfo.specialRole === specialRoles.DEFAULT_ROLE); +} + function roleIsAdminRole(roleInfo: ?RoleInfo): boolean { - return !!(roleInfo && !roleInfo.isDefault && roleInfo.name === 'Admins'); + return !!(roleInfo && roleInfo.specialRole === specialRoles.ADMIN_ROLE); } function threadHasAdminRole( @@ -1370,8 +1374,8 @@ } function checkIfDefaultMembersAreVoiced(threadInfo: ThreadInfo): boolean { - const defaultRoleID = Object.keys(threadInfo.roles).find( - roleID => threadInfo.roles[roleID].isDefault, + const defaultRoleID = Object.keys(threadInfo.roles).find(roleID => + roleIsDefaultRole(threadInfo.roles[roleID]), ); invariant( defaultRoleID !== undefined, @@ -1560,7 +1564,7 @@ if ( canRemoveMembers && !memberInfo.isViewer && - (canChangeRoles || threadInfo.roles[role]?.isDefault) + (canChangeRoles || roleIsDefaultRole(threadInfo.roles[role])) ) { result.push('remove_user'); } @@ -1792,6 +1796,7 @@ threadTypeDescriptions, memberIsAdmin, memberHasAdminPowers, + roleIsDefaultRole, roleIsAdminRole, threadHasAdminRole, identifyInvalidatedThreads,