Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] Fix/46963 hide card reconciliation button #46978

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ const ROUTES = {
},
WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS: {
route: 'settings/workspaces/:policyID/accounting/:connection/card-reconciliation/account',
getRoute: (policyID: string, connection: ValueOf<typeof CONST.POLICY.CONNECTIONS.NAME>) =>
getRoute: (policyID: string, connection?: ValueOf<typeof CONST.POLICY.CONNECTIONS.NAME>) =>
`settings/workspaces/${policyID}/accounting/${connection}/card-reconciliation/account` as const,
},
WORKSPACE_CATEGORIES: {
Expand Down
100 changes: 51 additions & 49 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -82,6 +83,7 @@ type AccountingIntegration = {
pendingFields?: PendingFields<string>;
errorFields?: ErrorFields;
};

function accountingIntegrationData(
connectionName: PolicyConnectionName,
policyID: string,
Expand Down Expand Up @@ -214,6 +216,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);
const [datetimeToRelative, setDateTimeToRelative] = useState('');
const threeDotsMenuContainerRef = useRef<View>(null);
const {canUseWorkspaceFeeds} = usePermissions();

const lastSyncProgressDate = parseISO(connectionSyncProgress?.timestamp ?? '');
const isSyncInProgress =
Expand Down Expand Up @@ -350,6 +353,52 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const shouldHideConfigurationOptions = isConnectionUnverified(policy, connectedIntegration);
const integrationData = accountingIntegrationData(connectedIntegration, policyID, translate, undefined, undefined, policy);
const iconProps = integrationData?.icon ? {icon: integrationData.icon, iconType: CONST.ICON_TYPE_AVATAR} : {};

const configurationOptions = [
{
icon: Expensicons.Pencil,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.import'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onImportPagePress,
brickRoadIndicator: areSettingsInErrorFields(integrationData?.subscribedImportSettings, integrationData?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
pendingAction: settingsPendingAction(integrationData?.subscribedImportSettings, integrationData?.pendingFields),
},
{
icon: Expensicons.Send,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.export'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onExportPagePress,
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,
},
{
icon: Expensicons.Gear,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.advanced'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onAdvancedPagePress,
brickRoadIndicator: areSettingsInErrorFields(integrationData?.subscribedAdvancedSettings, integrationData?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined,
pendingAction: settingsPendingAction(integrationData?.subscribedAdvancedSettings, integrationData?.pendingFields),
},
];

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

return [
{
...iconProps,
Expand Down Expand Up @@ -387,55 +436,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
),
},
...(isEmptyObject(integrationSpecificMenuItems) || shouldShowSynchronizationError || isEmptyObject(policy?.connections) ? [] : [integrationSpecificMenuItems]),
...(isEmptyObject(policy?.connections) || shouldHideConfigurationOptions
? []
: [
{
icon: Expensicons.Pencil,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.import'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onImportPagePress,
brickRoadIndicator: areSettingsInErrorFields(integrationData?.subscribedImportSettings, integrationData?.errorFields)
? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR
: undefined,
pendingAction: settingsPendingAction(integrationData?.subscribedImportSettings, integrationData?.pendingFields),
},
{
icon: Expensicons.Send,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.export'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onExportPagePress,
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,
},

{
icon: Expensicons.Gear,
iconRight: Expensicons.ArrowRight,
shouldShowRightIcon: true,
title: translate('workspace.accounting.advanced'),
wrapperStyle: [styles.sectionMenuItemTopDescription],
onPress: integrationData?.onAdvancedPagePress,
brickRoadIndicator: areSettingsInErrorFields(integrationData?.subscribedAdvancedSettings, integrationData?.errorFields)
? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR
: undefined,
pendingAction: settingsPendingAction(integrationData?.subscribedAdvancedSettings, integrationData?.pendingFields),
},
]),
...(isEmptyObject(policy?.connections) || shouldHideConfigurationOptions ? [] : configurationOptions),
];
}, [
policy,
Expand All @@ -447,6 +448,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
styles.pb0,
styles.mt5,
styles.popoverMenuIcon,
canUseWorkspaceFeeds,
connectionSyncProgress?.stageInProgress,
datetimeToRelative,
theme.spinner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
// import * as CardUtils from '@libs/CardUtils';
import {getLastFourDigits} from '@libs/BankAccountUtils';
import * as CardUtils from '@libs/CardUtils';
import Navigation from '@navigation/Navigation';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
Expand All @@ -33,20 +33,13 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP
const policyID = route.params?.policyID ?? '-1';
const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`);
// TODO: uncomment after integration with the BE
// const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policyID}`);
// const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policyID}`);

// TODO: remove after integration with the BE
const isUsedContinuousReconciliation = true;
const reconciliationConnection = CONST.POLICY.CONNECTIONS.NAME.QBO;
const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policyID}`);
const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policyID}`);

const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? '';
const paymentBankAccountNumber = bankAccountsList?.[paymentBankAccountID]?.accountData?.accountNumber ?? '';

// TODO: for now not filtering the accounts for easier testing
// const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountsList ?? {});
const eligibleBankAccounts = Object.values(bankAccountsList ?? {});
const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountsList ?? {});

const data = useMemo(() => {
const options = eligibleBankAccounts.map((bankAccount) => {
Expand Down
Loading