diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 332c145c58c4..fc1ebd956300 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2048,42 +2048,9 @@ function openPolicyWorkflowsPage(policyID: string) { return; } - const onyxData: OnyxData = { - optimisticData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - key: `${ONYXKEYS.REIMBURSEMENT_ACCOUNT}${policyID}`, - value: { - isLoading: true, - }, - }, - ], - successData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - key: `${ONYXKEYS.REIMBURSEMENT_ACCOUNT}${policyID}`, - value: { - isLoading: false, - }, - }, - ], - failureData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - key: `${ONYXKEYS.REIMBURSEMENT_ACCOUNT}${policyID}`, - value: { - isLoading: false, - }, - }, - ], - }; - const params: OpenPolicyWorkflowsPageParams = {policyID}; - API.read(READ_COMMANDS.OPEN_POLICY_WORKFLOWS_PAGE, params, onyxData); + API.read(READ_COMMANDS.OPEN_POLICY_WORKFLOWS_PAGE, params); } function setPolicyIDForReimburseView(policyID: string) { diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index fb9a463de01a..37fad70d3dae 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -14,7 +14,6 @@ import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import * as ErrorUtils from '@libs/ErrorUtils'; -import BankAccount from '@libs/models/BankAccount'; import Navigation from '@libs/Navigation/Navigation'; import Permissions from '@libs/Permissions'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; @@ -30,7 +29,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {Beta, ReimbursementAccount, Session} from '@src/types/onyx'; +import type {Beta, Session} from '@src/types/onyx'; import ToggleSettingOptionRow from './ToggleSettingsOptionRow'; import type {ToggleSettingOptionRowProps} from './ToggleSettingsOptionRow'; import {getAutoReportingFrequencyDisplayNames} from './WorkspaceAutoReportingFrequencyPage'; @@ -39,14 +38,12 @@ import type {AutoReportingFrequencyKey} from './WorkspaceAutoReportingFrequencyP type WorkspaceWorkflowsPageOnyxProps = { /** Beta features list */ betas: OnyxEntry; - /** Reimbursement account details */ - reimbursementAccount: OnyxEntry; /** Policy details */ session: OnyxEntry; }; type WorkspaceWorkflowsPageProps = WithPolicyProps & WorkspaceWorkflowsPageOnyxProps & StackScreenProps; -function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, session}: WorkspaceWorkflowsPageProps) { +function WorkspaceWorkflowsPage({policy, betas, route, session}: WorkspaceWorkflowsPageProps) { const {translate, preferredLocale} = useLocalize(); const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); @@ -86,9 +83,12 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses }, []); const optionItems: ToggleSettingOptionRowProps[] = useMemo(() => { - const {accountNumber, state, bankName} = reimbursementAccount?.achData ?? {}; - const hasVBA = state === BankAccount.STATE.OPEN; - const bankDisplayName = bankName ? `${bankName} ${accountNumber ? `${accountNumber.slice(-5)}` : ''}` : ''; + const {accountNumber, addressName} = policy?.achAccount ?? {}; + const hasVBA = !!policy?.achAccount; + let bankDisplayName = addressName; + if (accountNumber && bankDisplayName !== accountNumber) { + bankDisplayName += accountNumber.slice(-5); + } const hasReimburserEmailError = !!policy?.errorFields?.reimburserEmail; const hasApprovalError = !!policy?.errorFields?.approvalMode; const hasDelayedSubmissionError = !!policy?.errorFields?.autoReporting; @@ -187,7 +187,7 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses ? translate('common.bankAccount') : translate('workflowsPage.connectBankAccount') } - description={state === BankAccount.STATE.OPEN ? bankDisplayName : undefined} + description={bankDisplayName} onPress={() => { if (!Policy.isCurrencySupportedForDirectReimbursement(policy?.outputCurrency ?? '')) { setIsCurrencyModalOpen(true); @@ -238,7 +238,6 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses onPressAutoReportingFrequency, preferredLocale, canUseDelayedSubmission, - reimbursementAccount?.achData, displayNameForAuthorizedPayer, session?.accountID, ]); @@ -264,7 +263,6 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy); const isPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); - const isLoading = reimbursementAccount?.isLoading && policy?.reimbursementChoice === undefined; return ( @@ -317,10 +313,6 @@ export default withPolicy( betas: { key: ONYXKEYS.BETAS, }, - reimbursementAccount: { - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - key: ({route}) => `${ONYXKEYS.REIMBURSEMENT_ACCOUNT}${route.params.policyID}`, - }, session: { key: ONYXKEYS.SESSION, }, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 5165fa2ee128..63a40d8f4acb 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -183,6 +183,13 @@ type Connections = { quickbooksOnline: Connection; }; +type ACHAccount = { + bankAccountID: number; + accountNumber: string; + routingNumber: string; + addressName: string; +}; + type AutoReportingOffset = number | ValueOf; type PolicyReportFieldType = 'text' | 'date' | 'dropdown' | 'formula'; @@ -417,6 +424,8 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Whether the Connections feature is enabled */ areConnectionsEnabled?: boolean; + + achAccount?: ACHAccount; } & Partial, 'generalSettings' | 'addWorkspaceRoom' >;