diff --git a/web/src/user_group_edit_members.ts b/web/src/user_group_edit_members.ts index 90110d81d5..67bc19fddd 100644 --- a/web/src/user_group_edit_members.ts +++ b/web/src/user_group_edit_members.ts @@ -220,7 +220,7 @@ function add_new_members({pill_user_ids}: {pill_user_ids: number[]}): void { deactivated_users.add(user_id); return false; } - if (user_groups.is_user_in_group(group.id, user_id)) { + if (user_groups.is_user_in_group(group.id, user_id, true)) { // we filter out already added users before sending // add member request as the endpoint is not so robust and // fails complete request if any already added member @@ -235,7 +235,7 @@ function add_new_members({pill_user_ids}: {pill_user_ids: number[]}): void { if ( user_id_set.has(current_user.user_id) && - user_groups.is_user_in_group(group.id, current_user.user_id) + user_groups.is_user_in_group(group.id, current_user.user_id, true) ) { // We don't want to send a request to add ourselves if we // are already added to this group. This case occurs diff --git a/web/src/user_groups.ts b/web/src/user_groups.ts index 5c4ccdfe6e..2172384c00 100644 --- a/web/src/user_groups.ts +++ b/web/src/user_groups.ts @@ -311,7 +311,11 @@ export function get_recursive_group_members(target_user_group: UserGroup): Set { assert.equal(user_groups.is_user_in_group(foo.id, 6), true); assert.equal(user_groups.is_user_in_group(foo.id, 3), false); + // Check when passing direct_member_only as true. + assert.equal(user_groups.is_user_in_group(admins.id, 1, true), true); + assert.equal(user_groups.is_user_in_group(admins.id, 6, true), false); + + assert.equal(user_groups.is_user_in_group(all.id, 2, true), true); + assert.equal(user_groups.is_user_in_group(all.id, 1, true), false); + assert.equal(user_groups.is_user_in_group(all.id, 6, true), false); + + assert.equal(user_groups.is_user_in_group(test.id, 4, true), true); + assert.equal(user_groups.is_user_in_group(test.id, 1, true), false); + assert.equal(user_groups.is_user_in_group(test.id, 6, true), false); + assert.equal(user_groups.is_user_in_setting_group(test.id, 4), true); assert.equal(user_groups.is_user_in_setting_group(test.id, 1), true); assert.equal(user_groups.is_user_in_setting_group(test.id, 6), true);