Skip to content

Commit

Permalink
Merge pull request #16338 from Expensify/marcaaron-hideAssignedGuides
Browse files Browse the repository at this point in the history
Filter out assigned guides from the policy members
  • Loading branch information
marcochavezf authored Mar 29, 2023
2 parents 3a145a1 + 0f0f885 commit dfb2222
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/libs/PolicyUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import Str from 'expensify-common/lib/str';
import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';

Expand Down Expand Up @@ -75,10 +76,20 @@ function shouldShowPolicy(policy, isOffline) {
);
}

/**
* @param {string} email
* @returns {boolean}
*/
function isExpensifyTeam(email) {
const emailDomain = Str.extractEmailDomain(email);
return emailDomain === CONST.EXPENSIFY_PARTNER_NAME || emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
}

export {
hasPolicyMemberError,
hasPolicyError,
hasCustomUnitsError,
getPolicyBrickRoadIndicatorStatus,
shouldShowPolicy,
isExpensifyTeam,
};
31 changes: 22 additions & 9 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import * as ReportUtils from '../../libs/ReportUtils';
import FormHelpMessage from '../../components/FormHelpMessage';
import TextInput from '../../components/TextInput';
import KeyboardDismissingFlatList from '../../components/KeyboardDismissingFlatList';
import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails';
import * as PolicyUtils from '../../libs/PolicyUtils';

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

/**
* @param {String} value
* @param {String} [value = '']
* @param {String} keyword
* @returns {Boolean}
*/
isKeywordMatch(value, keyword) {
isKeywordMatch(value = '', keyword) {
return value.trim().toLowerCase().includes(keyword);
}

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

data = _.reject(data, (member) => {
// If this policy is owned by Expensify then show all support (expensify.com or team.expensify.com) emails
if (PolicyUtils.isExpensifyTeam(lodashGet(this.props.policy, 'owner'))) {
return;
}

// We don't want to show guides as policy members unless the user is not a guide. Some customers get confused when they
// see random people added to their policy, but guides having access to the policies help set them up.
const isCurrentUserExpensifyTeam = PolicyUtils.isExpensifyTeam(this.props.currentUserPersonalDetails.login);
return !isCurrentUserExpensifyTeam && PolicyUtils.isExpensifyTeam(member.login);
});

_.each(data, (member) => {
if (member.login === this.props.session.email || member.login === this.props.policy.owner || member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
return;
Expand Down Expand Up @@ -426,13 +440,11 @@ class WorkspaceMembersPage extends React.Component {
/>
</View>
) : (
!_.isEmpty(policyMemberList) && (
<View style={[styles.ph5]}>
<Text style={[styles.textLabel, styles.colorMuted]}>
{this.props.translate('common.noResultsFound')}
</Text>
</View>
)
<View style={[styles.ph5]}>
<Text style={[styles.textLabel, styles.colorMuted]}>
{this.props.translate('common.noResultsFound')}
</Text>
</View>
)}
</View>
</FullPageNotFoundView>
Expand All @@ -458,4 +470,5 @@ export default compose(
key: ONYXKEYS.SESSION,
},
}),
withCurrentUserPersonalDetails,
)(WorkspaceMembersPage);

0 comments on commit dfb2222

Please sign in to comment.