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 @@ -1067,8 +1067,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( @@ -1399,8 +1403,8 @@ function checkIfDefaultMembersAreVoiced( threadInfo: ThreadInfo | MinimallyEncodedThreadInfo, ): 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, @@ -1583,7 +1587,7 @@ let newRole = null; for (const roleID in threadInfo.roles) { const role = threadInfo.roles[roleID]; - if (isCurrentlyAdmin && role.isDefault) { + if (isCurrentlyAdmin && roleIsDefaultRole(role)) { newRole = role.id; break; } else if (!isCurrentlyAdmin && roleIsAdminRole(role)) { @@ -1629,7 +1633,7 @@ if ( canRemoveMembers && !memberInfo.isViewer && - (canChangeRoles || threadInfo.roles[role]?.isDefault) + (canChangeRoles || roleIsDefaultRole(threadInfo.roles[role])) ) { result.push('remove_user'); } @@ -1858,6 +1862,7 @@ threadTypeDescriptions, memberIsAdmin, memberHasAdminPowers, + roleIsDefaultRole, roleIsAdminRole, threadHasAdminRole, identifyInvalidatedThreads,