Skip to content

Commit

Permalink
Merge pull request #45679 from Expensify/nikki-entity-menu
Browse files Browse the repository at this point in the history
Only show entity menu item if there are entities to select
  • Loading branch information
madmax330 committed Jul 22, 2024
2 parents 138578b + 26f31d8 commit b4c5ac5
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
}, [getDatetimeToRelative, successfulDate]);

const integrationSpecificMenuItems = useMemo(() => {
const sageIntacctEntityListLength = policy?.connections?.intacct?.data?.entities?.length;
const sageIntacctEntityList = policy?.connections?.intacct?.data?.entities ?? [];
const netSuiteSubsidiaryList = policy?.connections?.netsuite?.options?.data?.subsidiaryList ?? [];
switch (connectedIntegration) {
case CONST.POLICY.CONNECTIONS.NAME.XERO:
Expand Down Expand Up @@ -242,23 +242,25 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
},
};
case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT:
return {
description: translate('workspace.intacct.entity'),
iconRight: Expensicons.ArrowRight,
title: getCurrentSageIntacctEntityName(policy),
wrapperStyle: [styles.sectionMenuItemTopDescription],
titleStyle: styles.fontWeightNormal,
shouldShowRightIcon: !!sageIntacctEntityListLength,
shouldShowDescriptionOnTop: true,
pendingAction: policy?.connections?.intacct?.config?.pendingFields?.entity,
brickRoadIndicator: policy?.connections?.intacct?.config?.errorFields?.entity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
onPress: () => {
if (!sageIntacctEntityListLength) {
return;
}
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTITY.getRoute(policyID));
},
};
return !sageIntacctEntityList.length
? {}
: {
description: translate('workspace.intacct.entity'),
iconRight: Expensicons.ArrowRight,
title: getCurrentSageIntacctEntityName(policy),
wrapperStyle: [styles.sectionMenuItemTopDescription],
titleStyle: styles.fontWeightNormal,
shouldShowRightIcon: true,
shouldShowDescriptionOnTop: true,
pendingAction: policy?.connections?.intacct?.config?.pendingFields?.entity,
brickRoadIndicator: policy?.connections?.intacct?.config?.errorFields?.entity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
onPress: () => {
if (!sageIntacctEntityList.length) {
return;
}
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTITY.getRoute(policyID));
},
};
default:
return undefined;
}
Expand Down

0 comments on commit b4c5ac5

Please sign in to comment.