Fix groups modal not loading if admin access restricted (#9182)

This commit is contained in:
Thomas Rittson 2024-05-15 10:59:59 +10:00 committed by GitHub
parent 6ab7336c21
commit 0812f00d24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -273,12 +273,13 @@ export class GroupAddEditComponent implements OnInit, OnDestroy {
// If the current user is not already in the group and cannot add themselves, remove them from the list
if (restrictGroupAccess) {
const organizationUserId = this.members.find((m) => m.userId === activeAccount.id).id;
// organizationUserId may be null if accessing via a provider
const organizationUserId = this.members.find((m) => m.userId === activeAccount.id)?.id;
const isAlreadyInGroup = this.groupForm.value.members.some(
(m) => m.id === organizationUserId,
);
if (!isAlreadyInGroup) {
if (organizationUserId != null && !isAlreadyInGroup) {
this.members = this.members.filter((m) => m.id !== organizationUserId);
}
}