diff --git a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountPage.tsx b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountPage.tsx index e75abf87e36f..3c4d781804fb 100644 --- a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountPage.tsx +++ b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountPage.tsx @@ -27,10 +27,12 @@ function QuickbooksDesktopCompanyCardExpenseAccountPage({policy}: WithPolicyConn const nonReimbursable = qbdConfig?.export?.nonReimbursable; const nonReimbursableAccount = qbdConfig?.export?.nonReimbursableAccount; - const accountName = useMemo( - () => getQBDReimbursableAccounts(policy?.connections?.quickbooksDesktop, nonReimbursable).find(({id}) => nonReimbursableAccount === id)?.name, - [policy?.connections?.quickbooksDesktop, nonReimbursable, nonReimbursableAccount], - ); + const accountName = useMemo(() => { + const qbdReimbursableAccounts = getQBDReimbursableAccounts(policy?.connections?.quickbooksDesktop, nonReimbursable); + // We use the logical OR (||) here instead of ?? because `nonReimbursableAccount` can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + return qbdReimbursableAccounts.find(({id}) => nonReimbursableAccount === id)?.name || qbdReimbursableAccounts.at(0)?.name || translate('workspace.qbd.notConfigured'); + }, [policy?.connections?.quickbooksDesktop, nonReimbursable, translate, nonReimbursableAccount]); const sections = [ { @@ -42,7 +44,7 @@ function QuickbooksDesktopCompanyCardExpenseAccountPage({policy}: WithPolicyConn keyForList: translate('workspace.accounting.exportAs'), }, { - title: accountName ?? translate('workspace.qbd.notConfigured'), + title: accountName, description: ConnectionUtils.getQBDNonReimbursableExportAccountType(nonReimbursable), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID)), subscribedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.NON_REIMBURSABLE_ACCOUNT], diff --git a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountSelectPage.tsx index d7cbf62c6d8b..c184f13f08c0 100644 --- a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopCompanyCardExpenseAccountSelectPage.tsx @@ -39,7 +39,9 @@ function QuickbooksDesktopCompanyCardExpenseAccountSelectPage({policy}: WithPoli value: card, text: card.name, keyForList: card.name, - isSelected: card.id === nonReimbursableAccount, + // We use the logical OR (||) here instead of ?? because `nonReimbursableAccount` can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + isSelected: card.id === (nonReimbursableAccount || accounts.at(0)?.id), })); }, [policy?.connections?.quickbooksDesktop, nonReimbursable, nonReimbursableAccount]); diff --git a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopNonReimbursableDefaultVendorSelectPage.tsx b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopNonReimbursableDefaultVendorSelectPage.tsx index bac01ce70ef1..edf97bd6f3eb 100644 --- a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopNonReimbursableDefaultVendorSelectPage.tsx +++ b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopNonReimbursableDefaultVendorSelectPage.tsx @@ -35,7 +35,9 @@ function QuickbooksDesktopNonReimbursableDefaultVendorSelectPage({policy}: WithP value: vendor.id, text: vendor.name, keyForList: vendor.name, - isSelected: vendor.id === nonReimbursableBillDefaultVendor, + // We use the logical OR (||) here instead of ?? because `nonReimbursableBillDefaultVendor` can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + isSelected: vendor.id === (nonReimbursableBillDefaultVendor || vendors.at(0)?.id), })) ?? []; return data.length ? [{data}] : []; }, [nonReimbursableBillDefaultVendor, vendors]); diff --git a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseAccountSelectPage.tsx index 86b30b52142f..936ce29fe2a1 100644 --- a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseAccountSelectPage.tsx @@ -58,7 +58,9 @@ function QuickbooksDesktopOutOfPocketExpenseAccountSelectPage({policy}: WithPoli value: account, text: account.name, keyForList: account.name, - isSelected: account.id === qbdConfig?.export?.reimbursableAccount, + // We use the logical OR (||) here instead of ?? because `reimbursableAccount` can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + isSelected: account.id === (qbdConfig?.export?.reimbursableAccount || accounts.at(0)?.id), })); }, [policy?.connections?.quickbooksDesktop, qbdConfig?.export?.reimbursableAccount]); diff --git a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseConfigurationPage.tsx index 08092465159b..1c0372aa8715 100644 --- a/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbd/export/QuickbooksDesktopOutOfPocketExpenseConfigurationPage.tsx @@ -74,7 +74,9 @@ function QuickbooksDesktopOutOfPocketExpenseConfigurationPage({policy}: WithPoli brickRoadIndicator: PolicyUtils.areSettingsInErrorFields(accountOrExportDestination, qbdConfig?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, }, { - title: accountsList.find(({id}) => qbdConfig?.export.reimbursableAccount === id)?.name ?? translate('workspace.qbd.notConfigured'), + // We use the logical OR (||) here instead of ?? because `reimbursableAccount` can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + title: accountsList.find(({id}) => qbdConfig?.export.reimbursableAccount === id)?.name || accountsList.at(0)?.name || translate('workspace.qbd.notConfigured'), description: accountDescription, onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID)), subscribedSettings: account,