Skip to content

Commit dfb2222

Browse files
authored
Merge pull request #16338 from Expensify/marcaaron-hideAssignedGuides
Filter out assigned guides from the policy members
2 parents 3a145a1 + 0f0f885 commit dfb2222

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/libs/PolicyUtils.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'underscore';
22
import lodashGet from 'lodash/get';
3+
import Str from 'expensify-common/lib/str';
34
import CONST from '../CONST';
45
import ONYXKEYS from '../ONYXKEYS';
56

@@ -75,10 +76,20 @@ function shouldShowPolicy(policy, isOffline) {
7576
);
7677
}
7778

79+
/**
80+
* @param {string} email
81+
* @returns {boolean}
82+
*/
83+
function isExpensifyTeam(email) {
84+
const emailDomain = Str.extractEmailDomain(email);
85+
return emailDomain === CONST.EXPENSIFY_PARTNER_NAME || emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
86+
}
87+
7888
export {
7989
hasPolicyMemberError,
8090
hasPolicyError,
8191
hasCustomUnitsError,
8292
getPolicyBrickRoadIndicatorStatus,
8393
shouldShowPolicy,
94+
isExpensifyTeam,
8495
};

src/pages/workspace/WorkspaceMembersPage.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import * as ReportUtils from '../../libs/ReportUtils';
3333
import FormHelpMessage from '../../components/FormHelpMessage';
3434
import TextInput from '../../components/TextInput';
3535
import KeyboardDismissingFlatList from '../../components/KeyboardDismissingFlatList';
36+
import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails';
37+
import * as PolicyUtils from '../../libs/PolicyUtils';
3638

3739
const propTypes = {
3840
/** The personal details of the person who is logged in */
@@ -247,11 +249,11 @@ class WorkspaceMembersPage extends React.Component {
247249
}
248250

249251
/**
250-
* @param {String} value
252+
* @param {String} [value = '']
251253
* @param {String} keyword
252254
* @returns {Boolean}
253255
*/
254-
isKeywordMatch(value, keyword) {
256+
isKeywordMatch(value = '', keyword) {
255257
return value.trim().toLowerCase().includes(keyword);
256258
}
257259

@@ -335,6 +337,18 @@ class WorkspaceMembersPage extends React.Component {
335337
|| this.isKeywordMatch(member.firstName, searchValue)
336338
|| this.isKeywordMatch(member.lastName, searchValue));
337339

340+
data = _.reject(data, (member) => {
341+
// If this policy is owned by Expensify then show all support (expensify.com or team.expensify.com) emails
342+
if (PolicyUtils.isExpensifyTeam(lodashGet(this.props.policy, 'owner'))) {
343+
return;
344+
}
345+
346+
// We don't want to show guides as policy members unless the user is not a guide. Some customers get confused when they
347+
// see random people added to their policy, but guides having access to the policies help set them up.
348+
const isCurrentUserExpensifyTeam = PolicyUtils.isExpensifyTeam(this.props.currentUserPersonalDetails.login);
349+
return !isCurrentUserExpensifyTeam && PolicyUtils.isExpensifyTeam(member.login);
350+
});
351+
338352
_.each(data, (member) => {
339353
if (member.login === this.props.session.email || member.login === this.props.policy.owner || member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
340354
return;
@@ -426,13 +440,11 @@ class WorkspaceMembersPage extends React.Component {
426440
/>
427441
</View>
428442
) : (
429-
!_.isEmpty(policyMemberList) && (
430-
<View style={[styles.ph5]}>
431-
<Text style={[styles.textLabel, styles.colorMuted]}>
432-
{this.props.translate('common.noResultsFound')}
433-
</Text>
434-
</View>
435-
)
443+
<View style={[styles.ph5]}>
444+
<Text style={[styles.textLabel, styles.colorMuted]}>
445+
{this.props.translate('common.noResultsFound')}
446+
</Text>
447+
</View>
436448
)}
437449
</View>
438450
</FullPageNotFoundView>
@@ -458,4 +470,5 @@ export default compose(
458470
key: ONYXKEYS.SESSION,
459471
},
460472
}),
473+
withCurrentUserPersonalDetails,
461474
)(WorkspaceMembersPage);

0 commit comments

Comments
 (0)