diff --git a/src/CONST.ts b/src/CONST.ts index d9c3b72d2d1a..d93eb230f779 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1858,7 +1858,6 @@ const CONST = { JOBS: 'jobs', }, }, - NETSUITE_CUSTOM_LIST_LIMIT: 8, NETSUITE_ADD_CUSTOM_LIST_STEP_NAMES: ['1', '2,', '3', '4'], NETSUITE_ADD_CUSTOM_SEGMENT_STEP_NAMES: ['1', '2,', '3', '4', '5', '6,'], }, @@ -4547,9 +4546,6 @@ const CONST = { }, INDENTS: ' ', PARENT_CHILD_SEPARATOR: ': ', - CATEGORY_LIST_THRESHOLD: 8, - TAG_LIST_THRESHOLD: 8, - TAX_RATES_LIST_THRESHOLD: 8, COLON: ':', MAPBOX: { PADDING: 32, @@ -4633,11 +4629,6 @@ const CONST = { */ MAX_SELECTION_LIST_PAGE_LENGTH: 500, - /** - * We only include the members search bar when we have 8 or more members - */ - SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT: 8, - /** * Bank account names */ @@ -4811,7 +4802,6 @@ const CONST = { WORKSPACE_SWITCHER: { NAME: 'Expensify', SUBSCRIPT_ICON_SIZE: 8, - MINIMUM_WORKSPACES_TO_SHOW_SEARCH: 8, }, WELCOME_VIDEO_URL: `${CLOUDFRONT_URL}/videos/intro-1280.mp4`, diff --git a/src/components/CategoryPicker.tsx b/src/components/CategoryPicker.tsx index 33d97c6909f5..0c855507371a 100644 --- a/src/components/CategoryPicker.tsx +++ b/src/components/CategoryPicker.tsx @@ -56,7 +56,7 @@ function CategoryPicker({selectedCategory, policyID, onSubmit}: CategoryPickerPr const categoryData = categoryOptions?.at(0)?.data ?? []; const header = OptionsListUtils.getHeaderMessageForNonUserList(categoryData.length > 0, debouncedSearchValue); const categoriesCount = OptionsListUtils.getEnabledCategoriesCount(categories); - const isCategoriesCountBelowThreshold = categoriesCount < CONST.CATEGORY_LIST_THRESHOLD; + const isCategoriesCountBelowThreshold = categoriesCount < CONST.STANDARD_LIST_ITEM_LIMIT; const showInput = !isCategoriesCountBelowThreshold; return [categoryOptions, header, showInput]; diff --git a/src/components/TagPicker/index.tsx b/src/components/TagPicker/index.tsx index 9d3a70d4d50c..a64c4c276606 100644 --- a/src/components/TagPicker/index.tsx +++ b/src/components/TagPicker/index.tsx @@ -52,7 +52,7 @@ function TagPicker({selectedTag, tagListName, policyID, tagListIndex, shouldShow const policyRecentlyUsedTagsList = useMemo(() => policyRecentlyUsedTags?.[tagListName] ?? [], [policyRecentlyUsedTags, tagListName]); const policyTagList = PolicyUtils.getTagList(policyTags, tagListIndex); const policyTagsCount = PolicyUtils.getCountOfEnabledTagsOfList(policyTagList.tags); - const isTagsCountBelowThreshold = policyTagsCount < CONST.TAG_LIST_THRESHOLD; + const isTagsCountBelowThreshold = policyTagsCount < CONST.STANDARD_LIST_ITEM_LIMIT; const shouldShowTextInput = !isTagsCountBelowThreshold; diff --git a/src/components/TaxPicker.tsx b/src/components/TaxPicker.tsx index 78ccb1425e21..a91965811d81 100644 --- a/src/components/TaxPicker.tsx +++ b/src/components/TaxPicker.tsx @@ -1,33 +1,21 @@ import React, {useCallback, useMemo, useState} from 'react'; -import {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import type {EdgeInsets} from 'react-native-safe-area-context'; import type {ValueOf} from 'type-fest'; import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import * as IOUUtils from '@libs/IOUUtils'; import * as OptionsListUtils from '@libs/OptionsListUtils'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import type {IOUAction} from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Policy, Transaction} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import SelectionList from './SelectionList'; import RadioListItem from './SelectionList/RadioListItem'; -type TaxPickerOnyxProps = { - /** The policy which the user has access to and which the report is tied to */ - policy: OnyxEntry; - - /** All the data for the transaction */ - transaction: OnyxEntry; - - /** The draft transaction that holds data to be persisted on the current split transaction */ - splitDraftTransaction: OnyxEntry; -}; - -type TaxPickerProps = TaxPickerOnyxProps & { +type TaxPickerProps = { /** The selected tax rate of an expense */ selectedTaxRate?: string; @@ -58,10 +46,16 @@ type TaxPickerProps = TaxPickerOnyxProps & { onDismiss: () => void; }; -function TaxPicker({selectedTaxRate = '', policy, transaction, insets, onSubmit, action, splitDraftTransaction, iouType, onDismiss}: TaxPickerProps) { +function TaxPicker({selectedTaxRate = '', policyID, transactionID, insets, onSubmit, action, iouType, onDismiss}: TaxPickerProps) { const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); const [searchValue, setSearchValue] = useState(''); + const policy = PolicyUtils.getPolicy(policyID); + const [draftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}` as `${typeof ONYXKEYS.COLLECTION.TRANSACTION}${string}`); + const [defaultTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`); + const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`); + + const transaction = IOUUtils.shouldUseTransactionDraft(action) ? draftTransaction : defaultTransaction; const isEditing = action === CONST.IOU.ACTION.EDIT; const isEditingSplitBill = isEditing && iouType === CONST.IOU.TYPE.SPLIT; @@ -69,7 +63,7 @@ function TaxPicker({selectedTaxRate = '', policy, transaction, insets, onSubmit, const taxRates = policy?.taxRates; const taxRatesCount = TransactionUtils.getEnabledTaxRateCount(taxRates?.taxes ?? {}); - const isTaxRatesCountBelowThreshold = taxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD; + const isTaxRatesCountBelowThreshold = taxRatesCount < CONST.STANDARD_LIST_ITEM_LIMIT; const shouldShowTextInput = !isTaxRatesCountBelowThreshold; @@ -125,19 +119,4 @@ function TaxPicker({selectedTaxRate = '', policy, transaction, insets, onSubmit, TaxPicker.displayName = 'TaxPicker'; -export default withOnyx({ - policy: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - }, - transaction: { - key: ({transactionID, action}) => { - if (IOUUtils.shouldUseTransactionDraft(action)) { - return `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}` as `${typeof ONYXKEYS.COLLECTION.TRANSACTION}${string}`; - } - return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; - }, - }, - splitDraftTransaction: { - key: ({transactionID}) => `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, - }, -})(TaxPicker); +export default TaxPicker; diff --git a/src/libs/API/parameters/SetCompanyCardExportAccountParams.ts b/src/libs/API/parameters/SetCompanyCardExportAccountParams.ts index 861345ff9c55..09f7b1340a36 100644 --- a/src/libs/API/parameters/SetCompanyCardExportAccountParams.ts +++ b/src/libs/API/parameters/SetCompanyCardExportAccountParams.ts @@ -1,7 +1,7 @@ type SetCompanyCardExportAccountParams = { authToken?: string | null; cardID: number; - exportAccountDetails: Record; + exportAccountDetails: string; }; export default SetCompanyCardExportAccountParams; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f6decd6fb2f4..5dec20777dcc 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1126,7 +1126,7 @@ function getCategoryListSections( const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name); const filteredCategories = enabledCategories.filter((category) => !selectedOptionNames.includes(category.name)); - if (numberOfEnabledCategories < CONST.CATEGORY_LIST_THRESHOLD) { + if (numberOfEnabledCategories < CONST.STANDARD_LIST_ITEM_LIMIT) { const data = getCategoryOptionTree(filteredCategories, false, selectedOptionsWithDisabledState); categorySections.push({ // "All" section when items amount less than the threshold @@ -1249,7 +1249,7 @@ function getTagListSections( return tagSections; } - if (numberOfTags < CONST.TAG_LIST_THRESHOLD) { + if (numberOfTags < CONST.STANDARD_LIST_ITEM_LIMIT) { tagSections.push({ // "All" section when items amount less than the threshold title: '', @@ -1459,7 +1459,7 @@ function getTaxRatesSection(policy: OnyxEntry | undefined, selectedOptio return policyRatesSections; } - if (numberOfTaxRates < CONST.TAX_RATES_LIST_THRESHOLD) { + if (numberOfTaxRates < CONST.STANDARD_LIST_ITEM_LIMIT) { policyRatesSections.push({ // "All" section when items amount less than the threshold title: '', diff --git a/src/libs/actions/CompanyCards.ts b/src/libs/actions/CompanyCards.ts index 18779a284278..7ec337610f06 100644 --- a/src/libs/actions/CompanyCards.ts +++ b/src/libs/actions/CompanyCards.ts @@ -493,25 +493,23 @@ function updateCompanyCardName(workspaceAccountID: number, cardID: string, newCa API.write(WRITE_COMMANDS.UPDATE_COMPANY_CARD_NAME, parameters, {optimisticData, finallyData, failureData}); } -function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bankName: string) { +function setCompanyCardExportAccount(policyID: string, workspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bank: string) { const authToken = NetworkStore.getAuthToken(); const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bank}`, value: { [cardID]: { nameValuePairs: { pendingFields: { - exportAccountDetails: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + [accountKey]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, errorFields: { - exportAccountDetails: null, - }, - exportAccountDetails: { - [accountKey]: newAccount, + [accountKey]: null, }, + [accountKey]: newAccount, }, }, }, @@ -521,12 +519,12 @@ function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, const finallyData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bank}`, value: { [cardID]: { nameValuePairs: { pendingFields: { - exportAccountDetails: null, + [accountKey]: null, }, }, }, @@ -536,15 +534,15 @@ function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, const failureData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`, + key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bank}`, value: { [cardID]: { nameValuePairs: { pendingFields: { - exportAccountDetails: null, + [accountKey]: newAccount, }, errorFields: { - exportAccountDetails: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + [accountKey]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), }, }, }, @@ -555,7 +553,7 @@ function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, const parameters: SetCompanyCardExportAccountParams = { authToken, cardID: Number(cardID), - exportAccountDetails: {[accountKey]: newAccount}, + exportAccountDetails: JSON.stringify({[accountKey]: newAccount, [`${accountKey}_policy_id`]: policyID}), }; API.write(WRITE_COMMANDS.SET_CARD_EXPORT_ACCOUNT, parameters, {optimisticData, finallyData, failureData}); @@ -577,6 +575,15 @@ function clearCompanyCardErrorField(workspaceAccountID: number, cardID: string, }, }, }); + Onyx.merge(ONYXKEYS.CARD_LIST, { + [cardID]: { + nameValuePairs: { + errorFields: { + [fieldName]: null, + }, + }, + }, + }); } function openPolicyCompanyCardsPage(policyID: string, workspaceAccountID: number) { diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index 405e1dd688f2..1c91023f2d6f 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -91,7 +91,7 @@ function ReportParticipantsPage({report, route}: ReportParticipantsPageProps) { }); // Include the search bar when there are 8 or more active members in the selection list - const shouldShowTextInput = activeParticipants.length >= CONST.SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT; + const shouldShowTextInput = activeParticipants.length >= CONST.STANDARD_LIST_ITEM_LIMIT; useEffect(() => { if (!isFocused) { diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index 6a89eca6f778..37b96514cb63 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -183,7 +183,7 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) { // When offline, we want to include the pending members with delete action as they are displayed in the list as well return !pendingMember || isOffline || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; }); - return activeParticipants.length >= CONST.SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT; + return activeParticipants.length >= CONST.STANDARD_LIST_ITEM_LIMIT; }, [participants, personalDetails, isOffline, report]); useEffect(() => { diff --git a/src/pages/WorkspaceSwitcherPage/index.tsx b/src/pages/WorkspaceSwitcherPage/index.tsx index d4d59638b592..e418c5d5df59 100644 --- a/src/pages/WorkspaceSwitcherPage/index.tsx +++ b/src/pages/WorkspaceSwitcherPage/index.tsx @@ -188,7 +188,7 @@ function WorkspaceSwitcherPage() { ListItem={UserListItem} sections={sections} onSelectRow={selectPolicy} - textInputLabel={usersWorkspaces.length >= CONST.WORKSPACE_SWITCHER.MINIMUM_WORKSPACES_TO_SHOW_SEARCH ? translate('common.search') : undefined} + textInputLabel={usersWorkspaces.length >= CONST.STANDARD_LIST_ITEM_LIMIT ? translate('common.search') : undefined} textInputValue={searchTerm} onChangeText={setSearchTerm} headerMessage={headerMessage} diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteCustomListSelectorModal.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteCustomListSelectorModal.tsx index e8f0d9e8315f..0f52f6a11d7c 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteCustomListSelectorModal.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomFieldNew/NetSuiteCustomListSelectorModal.tsx @@ -61,7 +61,7 @@ function NetSuiteCustomListSelectorModal({isVisible, currentCustomListValue, onC }, ], headerMessage: isEmpty ? translate('common.noResultsFound') : '', - showTextInput: customListData.length > CONST.NETSUITE_CONFIG.NETSUITE_CUSTOM_LIST_LIMIT, + showTextInput: customListData.length > CONST.STANDARD_LIST_ITEM_LIMIT, }; }, [debouncedSearchValue, policy?.connections?.netsuite?.options?.data?.customLists, translate, currentCustomListValue]); diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx index c32cebd7ba18..a39a4401cb6e 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx @@ -63,7 +63,7 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard if (!exportMenuItem?.exportType) { return; } - CompanyCards.setCompanyCardExportAccount(workspaceAccountID, cardID, exportMenuItem.exportType, value, bank); + CompanyCards.setCompanyCardExportAccount(policyID, workspaceAccountID, cardID, exportMenuItem.exportType, value, bank); Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, cardID, bank)); }, diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx index 4bdf5211a2c0..9fdfa7bec7b3 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx @@ -130,12 +130,17 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_NAME.getRoute(policyID, cardID, bank))} /> - {!!exportMenuItem && ( + {exportMenuItem?.shouldShowMenuItem ? ( CompanyCards.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, 'exportAccountDetails')} + errors={exportMenuItem.exportType ? ErrorUtils.getLatestErrorField(card?.nameValuePairs ?? {}, exportMenuItem.exportType) : undefined} + onClose={() => { + if (!exportMenuItem.exportType) { + return; + } + CompanyCards.clearCompanyCardErrorField(workspaceAccountID, cardID, bank, exportMenuItem.exportType); + }} > Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_EXPORT.getRoute(policyID, cardID, bank))} /> - )} + ) : null} void; data: SelectorType[]; - exportType?: string; + exportType?: ValueOf; + shouldShowMenuItem?: boolean; }; function getExportMenuItem( @@ -32,10 +34,11 @@ function getExportMenuItem( ): ExportIntegration | undefined { const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy); - const {nonReimbursableExpensesExportDestination} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {nonReimbursableExpensesExportDestination, nonReimbursableExpensesAccount} = policy?.connections?.quickbooksOnline?.config ?? {}; const {export: exportConfig} = policy?.connections?.intacct?.config ?? {}; const {export: exportConfiguration} = policy?.connections?.xero?.config ?? {}; const config = policy?.connections?.netsuite?.options.config; + const {bankAccounts} = policy?.connections?.xero?.data ?? {}; const {creditCards, bankAccounts: quickbooksOnlineBankAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; switch (connectionName) { @@ -43,20 +46,22 @@ function getExportMenuItem( const type = nonReimbursableExpensesExportDestination ? translate(`workspace.qbo.accounts.${nonReimbursableExpensesExportDestination}`) : undefined; const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined; let data: Account[]; + let shouldShowMenuItem = true; let title: string | undefined = ''; - let exportType: string | undefined = ''; + let exportType: ValueOf | undefined; switch (nonReimbursableExpensesExportDestination) { case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.CREDIT_CARD: data = creditCards ?? []; - title = companyCard?.nameValuePairs?.exportAccountDetails?.quickbooks_desktop_export_account_credit; + title = companyCard?.nameValuePairs?.quickbooks_desktop_export_account_credit ?? nonReimbursableExpensesAccount?.name; exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_QUICKBOOKS_DESKTOP_EXPORT_ACCOUNT_CREDIT; break; case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.DEBIT_CARD: data = quickbooksOnlineBankAccounts ?? []; - title = companyCard?.nameValuePairs?.exportAccountDetails?.quickbooks_online_export_account_debit; + title = companyCard?.nameValuePairs?.quickbooks_online_export_account_debit ?? nonReimbursableExpensesAccount?.name; exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_QUICKBOOKS_ONLINE_EXPORT_ACCOUNT_DEBIT; break; default: + shouldShowMenuItem = false; data = []; } @@ -64,6 +69,7 @@ function getExportMenuItem( description, title, exportType, + shouldShowMenuItem, onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), data: data.map((card) => ({ value: card.name, @@ -77,10 +83,12 @@ function getExportMenuItem( const type = translate('workspace.xero.xeroBankAccount'); const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined; const exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_XERO_EXPORT_BANK_ACCOUNT; + const selectedAccount = (bankAccounts ?? []).find((bank) => bank.id === exportConfiguration?.nonReimbursableAccount); return { description, exportType, - title: companyCard?.nameValuePairs?.exportAccountDetails?.xero_export_bank_account, + shouldShowMenuItem: true, + title: companyCard?.nameValuePairs?.xero_export_bank_account ?? selectedAccount?.name ?? bankAccounts?.[0]?.name ?? '', onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID)), data: getXeroBankAccounts(policy ?? undefined, exportConfiguration?.nonReimbursableAccount), }; @@ -90,27 +98,29 @@ function getExportMenuItem( ? translate(`workspace.netsuite.exportDestination.values.${config.nonreimbursableExpensesExportDestination}.label`) : undefined; let title: string | undefined = ''; - let exportType: string | undefined = ''; + let exportType: ValueOf | undefined; + let shouldShowMenuItem = true; const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined; let data: SelectorType[]; switch (config?.nonreimbursableExpensesExportDestination) { case CONST.NETSUITE_EXPORT_DESTINATION.VENDOR_BILL: - title = companyCard?.nameValuePairs?.exportAccountDetails?.netsuite_export_vendor; data = getNetSuiteVendorOptions(policy ?? undefined, config?.defaultVendor); + title = companyCard?.nameValuePairs?.netsuite_export_vendor ?? data.find((exportVendor) => exportVendor.isSelected)?.text; exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_NETSUITE_EXPORT_VENDOR; break; case CONST.NETSUITE_EXPORT_DESTINATION.JOURNAL_ENTRY: - title = companyCard?.nameValuePairs?.exportAccountDetails?.netsuite_export_payable_account; data = getNetSuitePayableAccountOptions(policy ?? undefined, config?.payableAcct); + title = companyCard?.nameValuePairs?.netsuite_export_payable_account ?? data.find((exportPayable) => exportPayable.isSelected)?.text; exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_NETSUITE_EXPORT_ACCOUNT; - break; default: + shouldShowMenuItem = false; data = []; } return { description, title, + shouldShowMenuItem, exportType, data, onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.getRoute(policyID)), @@ -121,13 +131,16 @@ function getExportMenuItem( const type = exportConfig?.nonReimbursable ? translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${exportConfig.nonReimbursable}`) : undefined; const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined; const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + const data = isVendor ? getSageIntacctVendors(policy, activeDefaultVendor) : getSageIntacctCreditCards(policy, exportConfig?.nonReimbursableAccount); + const selectedAccount = data.find((account) => account.isSelected)?.text; return { description, + shouldShowMenuItem: true, exportType: isVendor ? CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_INTACCT_EXPORT_VENDOR : CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_INTACCT_EXPORT_CHARGE_CARD, - title: isVendor ? companyCard?.nameValuePairs?.exportAccountDetails?.intacct_export_vendor : companyCard?.nameValuePairs?.exportAccountDetails?.intacct_export_charge_card, + title: isVendor ? companyCard?.nameValuePairs?.intacct_export_vendor ?? selectedAccount : companyCard?.nameValuePairs?.intacct_export_charge_card ?? selectedAccount, onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)), - data: isVendor ? getSageIntacctVendors(policy, activeDefaultVendor) : getSageIntacctCreditCards(policy, exportConfig?.nonReimbursableAccount), + data, }; } default: diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx index 1c952617dab5..2d47ef700e08 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx @@ -55,7 +55,7 @@ function WorkspaceWorkflowsApprovalsApproverPage({policy, personalDetails, isLoa const [approvalWorkflow] = useOnyx(ONYXKEYS.APPROVAL_WORKFLOW); const [selectedApproverEmail, setSelectedApproverEmail] = useState(undefined); const [allApprovers, setAllApprovers] = useState([]); - const shouldShowTextInput = allApprovers?.length >= 8; + const shouldShowTextInput = allApprovers?.length >= CONST.STANDARD_LIST_ITEM_LIMIT; // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundView = (isEmptyObject(policy) && !isLoadingReportData) || !PolicyUtils.isPolicyAdmin(policy) || PolicyUtils.isPendingDeletePolicy(policy); diff --git a/src/types/onyx/Card.ts b/src/types/onyx/Card.ts index c1d0e09d9312..8894db2723d1 100644 --- a/src/types/onyx/Card.ts +++ b/src/types/onyx/Card.ts @@ -2,10 +2,6 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; -/** Type of export card */ -type ExportCompanyCard = { - [key in ValueOf | ValueOf]: string; -}; /** Model of Expensify card */ type Card = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Card ID number */ @@ -76,9 +72,6 @@ type Card = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Type of card spending limits */ limitType?: ValueOf; - /** Type of export card */ - exportAccountDetails?: ExportCompanyCard; - /** User-defined nickname for the card */ cardTitle?: string; @@ -114,7 +107,11 @@ type Card = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Collection of form field errors */ errorFields?: OnyxCommon.ErrorFields; - }>; + }> & + OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Type of export card */ + [key in ValueOf | ValueOf]: string; + }>; }>; /** Model of Expensify card details */