Skip to content

Commit 911c07c

Browse files
authored
fix: remove disabled users from org tree in person card (#1973)
1 parent 2f03ee5 commit 911c07c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/mgt-components/src/components/mgt-person-card/mgt-person-card.graph.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { MgtPersonCardConfig, MgtPersonCardState } from './mgt-person-card.types
1414

1515
// tslint:disable-next-line:completed-docs
1616
const userProperties =
17-
'businessPhones,companyName,department,displayName,givenName,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName,id';
17+
'businessPhones,companyName,department,displayName,givenName,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName,id,accountEnabled';
1818

1919
// tslint:disable-next-line:completed-docs
2020
const batchKeys = {
@@ -94,6 +94,11 @@ export async function getPersonCardGraphData(
9494
}
9595
}
9696

97+
// filter out disabled users from direct reports.
98+
if (data.directReports && data.directReports.length > 0) {
99+
data.directReports = data.directReports.filter(report => report.accountEnabled);
100+
}
101+
97102
return data;
98103
}
99104

packages/mgt-components/src/graph/graph.people.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export async function findPeople(
111111
const scopes = 'people.read';
112112

113113
let cache: CacheStore<CachePeopleQuery>;
114-
let cacheKey = `${query}:${top}:${userType}`;
114+
const cacheKey = `${query}:${top}:${userType}`;
115115

116116
if (getIsPeopleCacheEnabled()) {
117117
cache = CacheService.getCache<CachePeopleQuery>(schemas.people, schemas.people.stores.peopleQuery);
@@ -145,7 +145,7 @@ export async function findPeople(
145145
.filter(filter)
146146
.middlewareOptions(prepScopes(scopes));
147147

148-
if (userType != UserType.contact) {
148+
if (userType !== UserType.contact) {
149149
// for any type other than Contact, user a wider search
150150
graphRequest = graphRequest.header('X-PeopleQuery-QuerySources', 'Mailbox,Directory');
151151
}
@@ -157,7 +157,9 @@ export async function findPeople(
157157
item.results = graphResult.value.map(personStr => JSON.stringify(personStr));
158158
cache.putValue(cacheKey, item);
159159
}
160-
} catch (error) {}
160+
} catch (error) {
161+
// intentionally empty
162+
}
161163
return graphResult ? graphResult.value : null;
162164
}
163165

@@ -175,7 +177,7 @@ export async function getPeople(
175177
const scopes = 'people.read';
176178

177179
let cache: CacheStore<CachePeopleQuery>;
178-
let cacheKey = peopleFilters ? peopleFilters : `*:${userType}`;
180+
const cacheKey = peopleFilters ? peopleFilters : `*:${userType}`;
179181

180182
if (getIsPeopleCacheEnabled()) {
181183
cache = CacheService.getCache<CachePeopleQuery>(schemas.people, schemas.people.stores.peopleQuery);
@@ -255,7 +257,7 @@ export async function findContactsByEmail(graph: IGraph, email: string): Promise
255257
}
256258
}
257259

258-
let encodedEmail = `${email.replace(/#/g, '%2523')}`;
260+
const encodedEmail = `${email.replace(/#/g, '%2523')}`;
259261

260262
const result = await graph
261263
.api('/me/contacts')

0 commit comments

Comments
 (0)