File tree Expand file tree Collapse file tree
apps/lfx-one/src/server/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ export function isFoundationAuditorOrgSelectorEnabled(): boolean {
4848 * single requests hitting gateway URL-length / access-check batch limits.
4949 */
5050export class FoundationAuditorOrgsService {
51+ // Active membership statuses (case-insensitive) — mirrors OrgMembershipResolverService and
52+ // OrgPeopleKeyContactsService so terminated/expired memberships don't surface stale member orgs.
53+ private static readonly activeMembershipStatuses = new Set ( [ 'active' , 'purchased' ] ) ;
54+
5155 private readonly microserviceProxy : MicroserviceProxyService ;
5256 private readonly accessCheck : AccessCheckService ;
5357
@@ -167,7 +171,11 @@ export class FoundationAuditorOrgsService {
167171 for ( const memberships of membershipsByIndex ) {
168172 for ( const membership of memberships ?? [ ] ) {
169173 const uid = membership . b2b_org_uid ;
170- if ( ! uid || seen . has ( uid ) || ! isFilterSafeIdentifier ( uid ) ) continue ;
174+ if ( ! uid || ! isFilterSafeIdentifier ( uid ) ) continue ;
175+ // Only active/purchased memberships count — an org with a terminated membership is no longer a
176+ // member. Status is checked BEFORE dedup so a stale row can't shadow the same org's active row.
177+ if ( ! FoundationAuditorOrgsService . activeMembershipStatuses . has ( ( membership . status ?? '' ) . toLowerCase ( ) ) ) continue ;
178+ if ( seen . has ( uid ) ) continue ;
171179 seen . add ( uid ) ;
172180 orderedUids . push ( uid ) ;
173181 if ( orderedUids . length >= FOUNDATION_AUDITOR_MEMBER_ORGS_HARD_CAP ) {
You can’t perform that action at this time.
0 commit comments