Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import RadioListItem from '@components/SelectionList/RadioListItem';
import type {ListItem} from '@components/SelectionList/types';
import SelectionScreen from '@components/SelectionScreen';
import Text from '@components/Text';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Connections from '@libs/actions/connections';
import {getAdminEmployees} from '@libs/PolicyUtils';
import {getAdminEmployees, isExpensifyTeam} from '@libs/PolicyUtils';
import Navigation from '@navigation/Navigation';
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
Expand All @@ -25,6 +26,7 @@ function XeroPreferredExporterSelectPage({policy}: WithPolicyConnectionsProps) {
const styles = useThemeStyles();
const policyOwner = policy?.owner ?? '';
const exporters = getAdminEmployees(policy);
const {login: currentUserLogin} = useCurrentUserPersonalDetails();

const policyID = policy?.id ?? '';
const data: CardListItem[] = useMemo(() => {
Expand All @@ -38,18 +40,26 @@ function XeroPreferredExporterSelectPage({policy}: WithPolicyConnectionsProps) {
},
];
}
return exporters?.reduce<CardListItem[]>((vendors, vendor) => {
if (vendor.email) {
vendors.push({
value: vendor.email,
text: vendor.email,
keyForList: vendor.email,
isSelected: exportConfiguration?.exporter === vendor.email,
});

return exporters?.reduce<CardListItem[]>((options, exporter) => {
if (!exporter.email) {
return options;
}

// Don't show guides if the current user is not a guide themselves or an Expensify employee
if (isExpensifyTeam(exporter.email) && !isExpensifyTeam(policyOwner) && !isExpensifyTeam(currentUserLogin)) {
return options;
}
return vendors;

options.push({
value: exporter.email,
text: exporter.email,
keyForList: exporter.email,
isSelected: exportConfiguration?.exporter === exporter.email,
});
return options;
}, []);
}, [exportConfiguration, exporters, policyOwner]);
}, [exportConfiguration, exporters, policyOwner, currentUserLogin]);

const selectExporter = useCallback(
(row: CardListItem) => {
Expand Down