Skip to content

Commit b4c5ac5

Browse files
authored
Merge pull request Expensify#45679 from Expensify/nikki-entity-menu
Only show entity menu item if there are entities to select
2 parents 138578b + 26f31d8 commit b4c5ac5

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/pages/workspace/accounting/PolicyAccountingPage.tsx

+20-18
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
202202
}, [getDatetimeToRelative, successfulDate]);
203203

204204
const integrationSpecificMenuItems = useMemo(() => {
205-
const sageIntacctEntityListLength = policy?.connections?.intacct?.data?.entities?.length;
205+
const sageIntacctEntityList = policy?.connections?.intacct?.data?.entities ?? [];
206206
const netSuiteSubsidiaryList = policy?.connections?.netsuite?.options?.data?.subsidiaryList ?? [];
207207
switch (connectedIntegration) {
208208
case CONST.POLICY.CONNECTIONS.NAME.XERO:
@@ -242,23 +242,25 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
242242
},
243243
};
244244
case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT:
245-
return {
246-
description: translate('workspace.intacct.entity'),
247-
iconRight: Expensicons.ArrowRight,
248-
title: getCurrentSageIntacctEntityName(policy),
249-
wrapperStyle: [styles.sectionMenuItemTopDescription],
250-
titleStyle: styles.fontWeightNormal,
251-
shouldShowRightIcon: !!sageIntacctEntityListLength,
252-
shouldShowDescriptionOnTop: true,
253-
pendingAction: policy?.connections?.intacct?.config?.pendingFields?.entity,
254-
brickRoadIndicator: policy?.connections?.intacct?.config?.errorFields?.entity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
255-
onPress: () => {
256-
if (!sageIntacctEntityListLength) {
257-
return;
258-
}
259-
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTITY.getRoute(policyID));
260-
},
261-
};
245+
return !sageIntacctEntityList.length
246+
? {}
247+
: {
248+
description: translate('workspace.intacct.entity'),
249+
iconRight: Expensicons.ArrowRight,
250+
title: getCurrentSageIntacctEntityName(policy),
251+
wrapperStyle: [styles.sectionMenuItemTopDescription],
252+
titleStyle: styles.fontWeightNormal,
253+
shouldShowRightIcon: true,
254+
shouldShowDescriptionOnTop: true,
255+
pendingAction: policy?.connections?.intacct?.config?.pendingFields?.entity,
256+
brickRoadIndicator: policy?.connections?.intacct?.config?.errorFields?.entity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
257+
onPress: () => {
258+
if (!sageIntacctEntityList.length) {
259+
return;
260+
}
261+
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTITY.getRoute(policyID));
262+
},
263+
};
262264
default:
263265
return undefined;
264266
}

0 commit comments

Comments
 (0)