diff --git a/apps/web/src/app/billing/services/free-families-policy.service.ts b/apps/web/src/app/billing/services/free-families-policy.service.ts index 10d7a9c6590..da569ffc993 100644 --- a/apps/web/src/app/billing/services/free-families-policy.service.ts +++ b/apps/web/src/app/billing/services/free-families-policy.service.ts @@ -7,7 +7,6 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { getUserId } from "@bitwarden/common/auth/services/account.service"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; interface EnterpriseOrgStatus { isFreeFamilyPolicyEnabled: boolean; @@ -27,19 +26,8 @@ export class FreeFamiliesPolicyService { private policyService: PolicyService, private organizationService: OrganizationService, private accountService: AccountService, - private configService: ConfigService, ) {} - canManageSponsorships$ = this.accountService.activeAccount$.pipe( - switchMap((account) => { - if (account?.id) { - return this.organizationService.canManageSponsorships$(account?.id); - } else { - return of(); - } - }), - ); - organizations$ = this.accountService.activeAccount$.pipe( switchMap((account) => { if (account?.id) { @@ -57,22 +45,21 @@ export class FreeFamiliesPolicyService { private getFreeFamiliesVisibility$(): Observable { return combineLatest([ this.checkEnterpriseOrganizationsAndFetchPolicy(), - this.canManageSponsorships$, + this.organizations$, ]).pipe( - map(([orgStatus, canManageSponsorships]) => - this.shouldShowFreeFamilyLink(orgStatus, canManageSponsorships), - ), + map(([orgStatus, organizations]) => this.shouldShowFreeFamilyLink(orgStatus, organizations)), ); } private shouldShowFreeFamilyLink( orgStatus: EnterpriseOrgStatus | null, - canManageSponsorships: boolean, + organizations: Organization[], ): boolean { if (!orgStatus) { return false; } const { belongToOneEnterpriseOrgs, isFreeFamilyPolicyEnabled } = orgStatus; + const canManageSponsorships = organizations.filter((org) => org.canManageSponsorships); return canManageSponsorships && !(belongToOneEnterpriseOrgs && isFreeFamilyPolicyEnabled); }