diff --git a/src/CONST.ts b/src/CONST.ts index d78629e95001..679f23ee6917 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -359,6 +359,7 @@ const CONST = { WORKFLOWS_DELAYED_SUBMISSION: 'workflowsDelayedSubmission', SPOTNANA_TRAVEL: 'spotnanaTravel', ACCOUNTING_ON_NEW_EXPENSIFY: 'accountingOnNewExpensify', + XERO_ON_NEW_EXPENSIFY: 'xeroOnNewExpensify', }, BUTTON_STATES: { DEFAULT: 'default', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index d01d97185c52..79955c0fdf30 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -44,6 +44,10 @@ function canUseAccountingIntegrations(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.ACCOUNTING_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); } +function canUseXeroIntegration(betas: OnyxEntry): boolean { + return !!betas?.includes(CONST.BETAS.XERO_ON_NEW_EXPENSIFY) || canUseAllBetas(betas); +} + /** * Link previews are temporarily disabled. */ @@ -62,4 +66,5 @@ export default { canUseWorkflowsDelayedSubmission, canUseSpotnanaTravel, canUseAccountingIntegrations, + canUseXeroIntegration, }; diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 48888c054813..1ecab8547b12 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -19,6 +19,7 @@ import ThreeDotsMenu from '@components/ThreeDotsMenu'; import type ThreeDotsMenuProps from '@components/ThreeDotsMenu/types'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import usePermissions from '@hooks/usePermissions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -47,8 +48,6 @@ type PolicyAccountingPageProps = WithPolicyProps & policy: Policy; }; -const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME); - type AccountingIntegration = { title: string; icon: IconAsset; @@ -105,12 +104,15 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting const styles = useThemeStyles(); const {translate} = useLocalize(); const {isOffline} = useNetwork(); + const {canUseXeroIntegration} = usePermissions(); const {isSmallScreenWidth, windowWidth} = useWindowDimensions(); const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState({horizontal: 0, vertical: 0}); const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false); const threeDotsMenuContainerRef = useRef(null); const isSyncInProgress = !!connectionSyncProgress?.stageInProgress && connectionSyncProgress.stageInProgress !== CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE; + + const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME).filter((name) => !(name === CONST.POLICY.CONNECTIONS.NAME.XERO && !canUseXeroIntegration)); const connectedIntegration = accountingIntegrations.find((integration) => !!policy?.connections?.[integration]) ?? connectionSyncProgress?.connectionName; const policyID = policy?.id ?? ''; @@ -258,6 +260,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting theme.spinner, threeDotsMenuPosition, translate, + accountingIntegrations, ]); const otherIntegrationsItems = useMemo(() => { @@ -279,7 +282,16 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting wrapperStyle: styles.sectionMenuItemTopDescription, }; }); - }, [connectedIntegration, connectionSyncProgress?.connectionName, isSyncInProgress, policy?.connections, policyID, styles.sectionMenuItemTopDescription, translate]); + }, [ + connectedIntegration, + connectionSyncProgress?.connectionName, + isSyncInProgress, + policy?.connections, + policyID, + styles.sectionMenuItemTopDescription, + translate, + accountingIntegrations, + ]); const headerThreeDotsMenuItems: ThreeDotsMenuProps['menuItems'] = [ {