Skip to content

Commit

Permalink
Merge pull request #53073 from daledah/fix/52548
Browse files Browse the repository at this point in the history
fix: hide reconciliation option if expensify card is not enabled
  • Loading branch information
mountiny authored Nov 30, 2024
2 parents 1a6f48e + 4c284fe commit fd13f39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type RouteParams = {

function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID ?? -1}`);
const theme = useTheme();
const styles = useThemeStyles();
const {translate, datetimeToRelative: getDatetimeToRelative} = useLocalize();
Expand Down Expand Up @@ -104,6 +105,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID);
const shouldShowSynchronizationError = !!synchronizationError;
const shouldShowReinstallConnectorMenuItem = shouldShowSynchronizationError && connectedIntegration === CONST.POLICY.CONNECTIONS.NAME.QBD;
const shouldShowCardReconciliationOption = policy?.areExpensifyCardsEnabled && cardSettings?.paymentBankAccountID;

const overflowMenu: ThreeDotsMenuProps['menuItems'] = useMemo(
() => [
Expand Down Expand Up @@ -306,14 +308,18 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
brickRoadIndicator: areSettingsInErrorFields(integrationData?.subscribedExportSettings, integrationData?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
pendingAction: settingsPendingAction(integrationData?.subscribedExportSettings, integrationData?.pendingFields),
},
{
icon: Expensicons.ExpensifyCard,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.cardReconciliation'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onCardReconciliationPagePress,
},
...(shouldShowCardReconciliationOption
? [
{
icon: Expensicons.ExpensifyCard,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.cardReconciliation'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onCardReconciliationPagePress,
},
]
: []),
{
icon: Expensicons.Gear,
iconRight: Expensicons.ArrowRight,
Expand All @@ -326,10 +332,6 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
},
];

if (!policy?.areExpensifyCardsEnabled) {
configurationOptions.splice(2, 1);
}

return [
{
...iconProps,
Expand Down Expand Up @@ -394,6 +396,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
startIntegrationFlow,
popoverAnchorRefs,
canUseNetSuiteUSATax,
shouldShowCardReconciliationOption,
]);

const otherIntegrationsItems = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
const {connection} = route.params;
const connectionName = AccountingUtils.getConnectionNameFromRouteParam(connection) as ConnectionName;
const autoSync = !!policy?.connections?.[connectionName]?.config?.autoSync?.enabled;
const shouldShow = policy?.areExpensifyCardsEnabled && cardSettings?.paymentBankAccountID;

const toggleContinuousReconciliation = (value: boolean) => {
Card.toggleContinuousReconciliation(workspaceAccountID, value, connectionName, currentConnectionName);
Expand Down Expand Up @@ -75,6 +76,7 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
policyID={policyID}
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
shouldBeBlocked={!shouldShow}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down

0 comments on commit fd13f39

Please sign in to comment.