Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
022d90f
feat: Link existing bank account
MrMuzyk Jul 24, 2025
2c5af1b
Merge branch 'main' of https://github.com/Expensify/App into feat/659…
MrMuzyk Jul 29, 2025
2537d00
fix: lint, ts
MrMuzyk Jul 29, 2025
4baca29
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Aug 11, 2025
ecd1746
chore: remove unused props and code
koko57 Aug 11, 2025
5ec8eda
feat: add missing translations
koko57 Aug 11, 2025
a8582c9
chore: remove AddPaymentMethodMenu, add a prop for addBankAccount button
koko57 Aug 11, 2025
6686f26
feat: add bankAccountID param
koko57 Aug 12, 2025
8df8459
chore: pass params as an object
koko57 Aug 12, 2025
ff95b63
fix: minor fix
koko57 Aug 12, 2025
190331f
fix: update optimistic data to show the bank properly
koko57 Aug 12, 2025
d24f70a
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Aug 12, 2025
46242a1
fix: prettier
koko57 Aug 12, 2025
43c1877
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Aug 12, 2025
2cf3627
fix: remove returning all betas
koko57 Aug 12, 2025
a8564c0
fix: minor fix
koko57 Aug 12, 2025
08fc7dd
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Aug 14, 2025
d5a5bff
fix: remove unused style
koko57 Aug 14, 2025
76ff0a2
fix: resolve conflicts
koko57 Aug 19, 2025
8f72b43
fix: eslint
koko57 Aug 19, 2025
c192f87
fix: wallet page margin, change route name
koko57 Aug 19, 2025
ea71651
fix: rename util to getEligibleExistingBusinessBankAccounts and move …
koko57 Aug 19, 2025
d39b8bc
fix: filter business bank accounts, do not show the badge
koko57 Aug 20, 2025
219e7e6
fix: navigation issue
koko57 Aug 20, 2025
62fd2f9
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Aug 20, 2025
d652664
fix: remove unnecessary prop and logic
koko57 Aug 20, 2025
17f3c48
fix: lint
koko57 Aug 20, 2025
135f9ef
fix: resolve conflicts
koko57 Aug 22, 2025
46ee4bf
fix: resolve conflicts
koko57 Aug 26, 2025
6e31a84
fix: temporarily revert the empty wrapper
koko57 Aug 26, 2025
448ebfb
fix: remove unused translation
koko57 Aug 26, 2025
12d9b02
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Aug 27, 2025
0c4160c
fix: show disconnect page when bank account added
koko57 Aug 27, 2025
36671b3
fix: resolve conflicts
koko57 Aug 28, 2025
4a2fdee
fix: resolve conflicts
koko57 Aug 29, 2025
9cd4180
fix: resolve conflicts
koko57 Sep 3, 2025
a2b3ae3
fix: eslint
koko57 Sep 3, 2025
0ae8d92
fix: continue setup modal
koko57 Sep 3, 2025
f7f863f
fix: prettier
koko57 Sep 3, 2025
811df70
Merge branch 'main' into feat/65912-connect-existing-account
koko57 Sep 3, 2025
daf29ad
fix: resolve conflicts
koko57 Sep 5, 2025
ba30fe3
fix: resolve conflicts
koko57 Sep 8, 2025
4fb93be
fix: resolve conflicts
koko57 Sep 15, 2025
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
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,10 @@ const ROUTES = {
return `workspaces/${policyID}/workflows` as const;
},
},
WORKSPACE_WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT: {
route: 'workspaces/:policyID/workflows/connect-account',
getRoute: (policyID: string) => `workspaces/${policyID}/workflows/connect-account` as const,
},
WORKSPACE_WORKFLOWS_APPROVALS_NEW: {
route: 'workspaces/:policyID/workflows/approvals/new',
getRoute: (policyID: string) => `workspaces/${policyID}/workflows/approvals/new` as const,
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ const SCREENS = {
WORKFLOWS_APPROVALS_APPROVER: 'Workspace_Workflows_Approvals_Approver',
WORKFLOWS_AUTO_REPORTING_FREQUENCY: 'Workspace_Workflows_Auto_Reporting_Frequency',
WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET: 'Workspace_Workflows_Auto_Reporting_Monthly_Offset',
WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT: 'Workspace_Workflows_Connect_Existing_Bank_Account',
DESCRIPTION: 'Workspace_Overview_Description',
SHARE: 'Workspace_Overview_Share',
NAME: 'Workspace_Overview_Name',
Expand Down
4 changes: 2 additions & 2 deletions src/components/AddToWalletButton/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {openWalletPage} from '@libs/actions/PaymentMethods';
import {getPaymentMethods} from '@libs/actions/PaymentMethods';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import {checkIfWalletIsAvailable, handleAddCardToWallet, isCardInWallet} from '@libs/Wallet/index';
Expand Down Expand Up @@ -42,7 +42,7 @@ function AddToWalletButton({card, cardHolderName, cardDescription, buttonStyle}:
.then((status: TokenizationStatus) => {
if (status === 'success') {
Log.info('Card added to wallet');
openWalletPage();
getPaymentMethods();
} else {
setIsLoading(false);
}
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5437,6 +5437,7 @@ const translations = {
updateWorkspaceCurrency: 'Arbeitsbereichswährung aktualisieren',
workspaceCurrencyNotSupported: 'Arbeitsbereichswährung wird nicht unterstützt',
yourWorkspace: `Ihr Arbeitsbereich ist auf eine nicht unterstützte Währung eingestellt. Sehen Sie sich die <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">Liste der unterstützten Währungen an</a>.`,
chooseAnExisting: 'Wählen Sie ein vorhandenes Bankkonto zur Zahlung von Ausgaben oder fügen Sie ein neues hinzu.',
},
changeOwner: {
changeOwnerPageTitle: 'Besitzer übertragen',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5411,6 +5411,7 @@ const translations = {
updateWorkspaceCurrency: 'Update workspace currency',
workspaceCurrencyNotSupported: 'Workspace currency not supported',
yourWorkspace: `Your workspace is set to an unsupported currency. View the <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">list of supported currencies</a>.`,
chooseAnExisting: 'Choose an existing bank account to pay expenses or add a new one.',
},
changeOwner: {
changeOwnerPageTitle: 'Transfer owner',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5425,6 +5425,7 @@ const translations = {
updateWorkspaceCurrency: 'Actualizar la moneda del espacio de trabajo',
workspaceCurrencyNotSupported: 'Moneda del espacio de trabajo no soportada',
yourWorkspace: `Tu espacio de trabajo está configurado en una moneda no soportada. Consulta la <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">lista de monedas soportadas</a>.`,
chooseAnExisting: 'Elige una cuenta bancaria existente para pagar gastos o añade una nueva.',
},
changeOwner: {
changeOwnerPageTitle: 'Transferir la propiedad',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5449,6 +5449,7 @@ const translations = {
updateWorkspaceCurrency: "Mettre à jour la devise de l'espace de travail",
workspaceCurrencyNotSupported: "Devise de l'espace de travail non prise en charge",
yourWorkspace: `Votre espace de travail est configuré avec une devise non prise en charge. Consultez la <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">liste des devises prises en charge</a>.`,
chooseAnExisting: 'Choisissez un compte bancaire existant pour payer les dépenses ou ajoutez-en un nouveau.',
},
changeOwner: {
changeOwnerPageTitle: 'Transférer le propriétaire',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5446,6 +5446,7 @@ const translations = {
updateWorkspaceCurrency: 'Aggiorna la valuta dello spazio di lavoro',
workspaceCurrencyNotSupported: "Valuta dell'area di lavoro non supportata",
yourWorkspace: `Il tuo spazio di lavoro è impostato su una valuta non supportata. Visualizza <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">l'elenco delle valute supportate</a>.`,
chooseAnExisting: 'Scegli un conto bancario esistente per pagare le spese o aggiungine uno nuovo.',
},
changeOwner: {
changeOwnerPageTitle: 'Trasferisci proprietario',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5416,6 +5416,7 @@ const translations = {
updateWorkspaceCurrency: 'ワークスペースの通貨を更新する',
workspaceCurrencyNotSupported: 'ワークスペース通貨はサポートされていません',
yourWorkspace: `ご使用のワークスペースは、サポートされていない通貨に設定されています。<a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">サポートされている通貨の一覧</a>をご確認ください。`,
chooseAnExisting: '既存の銀行口座を選択して経費を支払うか、新しい口座を追加してください。',
},
changeOwner: {
changeOwnerPageTitle: 'オーナーを移行',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5444,6 +5444,7 @@ const translations = {
updateWorkspaceCurrency: 'Werkruimte valuta bijwerken',
workspaceCurrencyNotSupported: 'Werkruimtevaluta niet ondersteund',
yourWorkspace: `Uw werkruimte is ingesteld op een niet-ondersteunde valuta. Bekijk de <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">lijst met ondersteunde valuta's</a>.`,
chooseAnExisting: 'Kies een bestaande bankrekening om uitgaven te betalen of voeg een nieuwe toe.',
},
changeOwner: {
changeOwnerPageTitle: 'Eigenaar overdragen',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5432,6 +5432,7 @@ const translations = {
updateWorkspaceCurrency: 'Zaktualizuj walutę przestrzeni roboczej',
workspaceCurrencyNotSupported: 'Waluta przestrzeni roboczej nie jest obsługiwana',
yourWorkspace: `Twoje miejsce pracy jest ustawione na nieobsługiwaną walutę. Zobacz <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">listę obsługiwanych walut</a>.`,
chooseAnExisting: 'Wybierz istniejące konto bankowe do płacenia wydatków lub dodaj nowe.',
},
changeOwner: {
changeOwnerPageTitle: 'Przenieś właściciela',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5443,6 +5443,7 @@ const translations = {
updateWorkspaceCurrency: 'Atualizar moeda do espaço de trabalho',
workspaceCurrencyNotSupported: 'Moeda do espaço de trabalho não suportada',
yourWorkspace: `Seu espaço de trabalho está configurado para uma moeda não suportada. Veja a <a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">lista de moedas suportadas</a>.`,
chooseAnExisting: 'Escolha uma conta bancária existente para pagar despesas ou adicione uma nova.',
},
changeOwner: {
changeOwnerPageTitle: 'Transferir proprietário',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5347,6 +5347,7 @@ const translations = {
updateWorkspaceCurrency: '更新工作区货币',
workspaceCurrencyNotSupported: '工作区货币不支持',
yourWorkspace: `您的工作区设置为不支持的货币。查看<a href="${CONST.CONNECT_A_BUSINESS_BANK_ACCOUNT_HELP_URL}">支持货币列表</a>。`,
chooseAnExisting: '选择现有银行账户支付费用或添加新账户。',
},
changeOwner: {
changeOwnerPageTitle: '转移所有者',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type CONST from '@src/CONST';
type SetWorkspaceReimbursementParams = {
policyID: string;
reimbursementChoice: ValueOf<typeof CONST.POLICY.REIMBURSEMENT_CHOICES>;
bankAccountID?: number;
};

export default SetWorkspaceReimbursementParams;
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_ITEMS]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopItemsPage').default,
[SCREENS.WORKSPACE.WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT]: () =>
require<ReactComponentModule>('../../../../pages/workspace/workflows/WorkspaceWorkflowsConnectExistingBankAccountPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default,
[SCREENS.REIMBURSEMENT_ACCOUNT_ENTER_SIGNER_INFO]: () => require<ReactComponentModule>('../../../../pages/ReimbursementAccount/EnterSignerInfo').default,
[SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: () => require<ReactComponentModule>('../../../../pages/settings/Wallet/ReportCardLostPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const WORKSPACE_TO_RHP: Partial<Record<keyof WorkspaceSplitNavigatorParamList, s
SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY,
SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET,
SCREENS.WORKSPACE.WORKFLOWS_PAYER,
SCREENS.WORKSPACE.WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT,
],
[SCREENS.WORKSPACE.ACCOUNTING.ROOT]: [
SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_IMPORT,
Expand Down
4 changes: 4 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,10 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.WORKSPACE.REPORT_FIELDS_EDIT_INITIAL_VALUE]: {
path: ROUTES.WORKSPACE_EDIT_REPORT_FIELDS_INITIAL_VALUE.route,
},
[SCREENS.WORKSPACE.WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT]: {
path: ROUTES.WORKSPACE_WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT.route,
exact: true,
},
[SCREENS.REIMBURSEMENT_ACCOUNT]: {
path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route,
exact: true,
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,9 @@ type WorkspaceSplitNavigatorParamList = {
[SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: {
policyID: string;
};
[SCREENS.WORKSPACE.WORKFLOWS_CONNECT_EXISTING_BANK_ACCOUNT]: {
policyID: string;
};
[SCREENS.WORKSPACE.INVOICES]: {
policyID: string;
};
Expand Down
25 changes: 23 additions & 2 deletions src/libs/ReimbursementAccountUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {ValueOf} from 'type-fest';
import CONST from '@src/CONST';
import type {ReimbursementAccountStep} from '@src/types/onyx/ReimbursementAccount';
import type {ACHDataReimbursementAccount, ReimbursementAccountStep} from '@src/types/onyx/ReimbursementAccount';

type ReimbursementAccountStepToOpen = ValueOf<typeof REIMBURSEMENT_ACCOUNT_ROUTE_NAMES> | '';

Expand Down Expand Up @@ -35,5 +35,26 @@ function getRouteForCurrentStep(currentStep: ReimbursementAccountStep): Reimburs
}
}

export {getRouteForCurrentStep, REIMBURSEMENT_ACCOUNT_ROUTE_NAMES};
/**
* Returns true if a VBBA exists in any state other than OPEN or LOCKED
*/
const hasInProgressUSDVBBA = (achData?: ACHDataReimbursementAccount): boolean => {
return !!achData?.bankAccountID && !!achData?.state && achData?.state !== CONST.BANK_ACCOUNT.STATE.OPEN && achData?.state !== CONST.BANK_ACCOUNT.STATE.LOCKED;
};

/** Returns true if user passed first step of flow for non USD VBBA */
const hasInProgressNonUSDVBBA = (achData?: ACHDataReimbursementAccount, nonUSDCountryDraftValue?: string): boolean => {
return (!!achData?.bankAccountID && !!achData?.created) || nonUSDCountryDraftValue !== '';
};

/** Returns true if VBBA flow is in progress */
const hasInProgressVBBA = (achData?: ACHDataReimbursementAccount, isNonUSDWorkspace?: boolean, nonUSDCountryDraftValue?: string) => {
if (isNonUSDWorkspace) {
return hasInProgressNonUSDVBBA(achData, nonUSDCountryDraftValue);
}

return hasInProgressUSDVBBA(achData);
};

export {getRouteForCurrentStep, REIMBURSEMENT_ACCOUNT_ROUTE_NAMES, hasInProgressUSDVBBA, hasInProgressNonUSDVBBA, hasInProgressVBBA};
export type {ReimbursementAccountStepToOpen};
24 changes: 23 additions & 1 deletion src/libs/WorkflowUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type {LocaleContextProps} from '@components/LocaleContextProvider';
import CONST from '@src/CONST';
import type {BankAccountList} from '@src/types/onyx';
import type {ApprovalWorkflowOnyx, Approver, Member} from '@src/types/onyx/ApprovalWorkflow';
import type ApprovalWorkflow from '@src/types/onyx/ApprovalWorkflow';
import type {PersonalDetailsList} from '@src/types/onyx/PersonalDetails';
Expand Down Expand Up @@ -304,6 +305,7 @@ function convertApprovalWorkflowToPolicyEmployees({

return updatedEmployeeList;
}

function updateWorkflowDataOnApproverRemoval({approvalWorkflows, removedApprover, ownerDetails}: UpdateWorkflowDataOnApproverRemovalParams): UpdateWorkflowDataOnApproverRemovalResult {
const defaultWorkflow = approvalWorkflows.find((workflow) => workflow.isDefault);
const removedApproverEmail = removedApprover.login;
Expand Down Expand Up @@ -414,4 +416,24 @@ function updateWorkflowDataOnApproverRemoval({approvalWorkflows, removedApprover
});
}

export {calculateApprovers, convertPolicyEmployeesToApprovalWorkflows, convertApprovalWorkflowToPolicyEmployees, INITIAL_APPROVAL_WORKFLOW, updateWorkflowDataOnApproverRemoval};
/**
* Get eligible business bank accounts for the workspace reimbursement workflow
*/
function getEligibleExistingBusinessBankAccounts(bankAccountList: BankAccountList | undefined, policyCurrency: string | undefined) {
if (!bankAccountList || policyCurrency === undefined) {
return [];
}

return Object.values(bankAccountList).filter((account) => {
return account.bankCurrency === policyCurrency && account.accountData?.state === CONST.BANK_ACCOUNT.STATE.OPEN && account.accountData?.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS;
});
}

export {
calculateApprovers,
convertPolicyEmployeesToApprovalWorkflows,
convertApprovalWorkflowToPolicyEmployees,
getEligibleExistingBusinessBankAccounts,
INITIAL_APPROVAL_WORKFLOW,
updateWorkflowDataOnApproverRemoval,
};
8 changes: 4 additions & 4 deletions src/libs/actions/PaymentMethods.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {createRef} from 'react';
import type {MutableRefObject} from 'react';
import type {RefObject} from 'react';
import type {GestureResponderEvent} from 'react-native';
import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
Expand Down Expand Up @@ -37,7 +37,7 @@ type KYCWallRef = {
/**
* Sets up a ref to an instance of the KYC Wall component.
*/
const kycWallRef: MutableRefObject<KYCWallRef | null> = createRef<KYCWallRef>();
const kycWallRef: RefObject<KYCWallRef | null> = createRef<KYCWallRef>();

/**
* When we successfully add a payment method or pass the KYC checks we will continue with our setup action if we have one set.
Expand All @@ -53,7 +53,7 @@ function continueSetup(fallbackRoute?: Route) {
kycWallRef.current.continueAction();
}

function openWalletPage() {
function getPaymentMethods() {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -582,7 +582,7 @@ function setInvoicingTransferBankAccount(bankAccountID: number, policyID: string
export {
deletePaymentCard,
addPaymentCard,
openWalletPage,
getPaymentMethods,
makeDefaultPaymentMethod,
kycWallRef,
continueSetup,
Expand Down
15 changes: 11 additions & 4 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@
policyCategories?: PolicyCategories;
};

type SetWorkspaceReimbursementActionParams = {
policyID: string;
reimbursementChoice: ValueOf<typeof CONST.POLICY.REIMBURSEMENT_CHOICES>;
bankAccountID?: number;
reimburserEmail: string;
};

const allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 193 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (val, key) => {
if (!key) {
Expand Down Expand Up @@ -216,7 +223,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 226 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -225,7 +232,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 235 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -235,7 +242,7 @@

let sessionEmail = '';
let sessionAccountID = 0;
Onyx.connect({

Check warning on line 245 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (val) => {
sessionEmail = val?.email ?? '';
Expand All @@ -244,38 +251,38 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 254 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => (allPersonalDetails = val),
});

let reimbursementAccount: OnyxEntry<ReimbursementAccount>;
Onyx.connect({

Check warning on line 260 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
callback: (val) => (reimbursementAccount = val),
});

let allRecentlyUsedCurrencies: string[];
Onyx.connect({

Check warning on line 266 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.RECENTLY_USED_CURRENCIES,
callback: (val) => (allRecentlyUsedCurrencies = val ?? []),
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 272 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});

let allTransactionViolations: OnyxCollection<TransactionViolations> = {};
Onyx.connect({

Check warning on line 278 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => (allTransactionViolations = value),
});

let introSelected: OnyxEntry<IntroSelected>;
Onyx.connect({

Check warning on line 285 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_INTRO_SELECTED,
callback: (value) => (introSelected = value),
});
Expand Down Expand Up @@ -866,7 +873,7 @@
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {quickbooksOnline: {config: {errorFields: {autoSync: null}}}}});
}

function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueOf<typeof CONST.POLICY.REIMBURSEMENT_CHOICES>, reimburserEmail: string) {
function setWorkspaceReimbursement({policyID, reimbursementChoice, bankAccountID, reimburserEmail}: SetWorkspaceReimbursementActionParams) {
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = getPolicy(policyID);
Expand All @@ -879,7 +886,7 @@
reimbursementChoice,
isLoadingWorkspaceReimbursement: true,
reimburser: reimburserEmail,
achAccount: {reimburser: reimburserEmail},
achAccount: {reimburser: reimburserEmail, bankAccountID},
errorFields: {reimbursementChoice: null},
pendingFields: {reimbursementChoice: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE},
},
Expand All @@ -905,14 +912,14 @@
value: {
isLoadingWorkspaceReimbursement: false,
reimbursementChoice: policy?.reimbursementChoice ?? null,
achAccount: {reimburser: policy?.achAccount?.reimburser ?? null},
achAccount: {reimburser: policy?.achAccount?.reimburser ?? null, bankAccountID: null},
errorFields: {reimbursementChoice: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')},
pendingFields: {reimbursementChoice: null},
},
},
];

const params: SetWorkspaceReimbursementParams = {policyID, reimbursementChoice};
const params: SetWorkspaceReimbursementParams = {policyID, reimbursementChoice, bankAccountID};

API.write(WRITE_COMMANDS.SET_WORKSPACE_REIMBURSEMENT, params, {optimisticData, failureData, successData});
}
Expand Down
Loading
Loading