diff --git a/src/components/SelectionListWithSections/Search/ActionCell.tsx b/src/components/SelectionListWithSections/Search/ActionCell.tsx deleted file mode 100644 index 9ce5307467853..0000000000000 --- a/src/components/SelectionListWithSections/Search/ActionCell.tsx +++ /dev/null @@ -1,201 +0,0 @@ -import React, {useCallback} from 'react'; -import {View} from 'react-native'; -import type {ValueOf} from 'type-fest'; -import Badge from '@components/Badge'; -import Button from '@components/Button'; -import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/DelegateNoAccessModalProvider'; -import type {PaymentMethod} from '@components/KYCWall/types'; -import {SearchScopeProvider} from '@components/Search/SearchScopeProvider'; -import SettlementButton from '@components/SettlementButton'; -import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; -import useLocalize from '@hooks/useLocalize'; -import useNetwork from '@hooks/useNetwork'; -import useOnyx from '@hooks/useOnyx'; -import usePolicy from '@hooks/usePolicy'; -import useReportWithTransactionsAndViolations from '@hooks/useReportWithTransactionsAndViolations'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import {canIOUBePaid} from '@libs/actions/IOU'; -import {getPayMoneyOnSearchInvoiceParams, payMoneyRequestOnSearch} from '@libs/actions/Search'; -import {convertToDisplayString} from '@libs/CurrencyUtils'; -import {isInvoiceReport} from '@libs/ReportUtils'; -import variables from '@styles/variables'; -import CONST from '@src/CONST'; -import type {TranslationPaths} from '@src/languages/types'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import type {SearchTransactionAction} from '@src/types/onyx/SearchResults'; - -const actionTranslationsMap: Record = { - view: 'common.view', - submit: 'common.submit', - approve: 'iou.approve', - pay: 'iou.pay', - exportToAccounting: 'common.export', - done: 'common.done', - paid: 'iou.settledExpensify', -}; - -type ActionCellProps = { - action?: SearchTransactionAction; - isLargeScreenWidth?: boolean; - isSelected?: boolean; - goToItem: () => void; - isChildListItem?: boolean; - parentAction?: string; - isLoading?: boolean; - policyID?: string; - reportID?: string; - hash?: number; - amount?: number; - extraSmall?: boolean; - shouldDisablePointerEvents?: boolean; -}; - -function ActionCell({ - action = CONST.SEARCH.ACTION_TYPES.VIEW, - isLargeScreenWidth = true, - isSelected = false, - goToItem, - isChildListItem = false, - parentAction = '', - isLoading = false, - policyID = '', - reportID = '', - hash, - amount, - extraSmall = false, - shouldDisablePointerEvents, -}: ActionCellProps) { - const {translate} = useLocalize(); - const theme = useTheme(); - const styles = useThemeStyles(); - const StyleUtils = useStyleUtils(); - const {isOffline} = useNetwork(); - const expensifyIcons = useMemoizedLazyExpensifyIcons(['Checkmark', 'Checkbox']); - const {isDelegateAccessRestricted} = useDelegateNoAccessState(); - const {showDelegateNoAccessModal} = useDelegateNoAccessActions(); - const [iouReport, transactions] = useReportWithTransactionsAndViolations(reportID); - const policy = usePolicy(policyID); - const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true}); - const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReport?.chatReportID}`, {canBeMissing: true}); - const canBePaid = canIOUBePaid(iouReport, chatReport, policy, bankAccountList, transactions, false); - const shouldOnlyShowElsewhere = !canBePaid && canIOUBePaid(iouReport, chatReport, policy, bankAccountList, transactions, true); - const text = isChildListItem ? translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW]) : translate(actionTranslationsMap[action]); - const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || (parentAction === CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID); - - const {currency} = iouReport ?? {}; - - const confirmPayment = useCallback( - (type: ValueOf | undefined, payAsBusiness?: boolean, methodID?: number, paymentMethod?: PaymentMethod | undefined) => { - if (!type || !reportID || !hash || !amount) { - return; - } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - - const invoiceParams = getPayMoneyOnSearchInvoiceParams(policyID, payAsBusiness, methodID, paymentMethod); - payMoneyRequestOnSearch(hash, [{amount, paymentType: type, reportID, ...(isInvoiceReport(iouReport) ? invoiceParams : {})}]); - }, - [reportID, hash, amount, policyID, iouReport, isDelegateAccessRestricted, showDelegateNoAccessModal], - ); - - if (!isChildListItem && ((parentAction !== CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID) || action === CONST.SEARCH.ACTION_TYPES.DONE)) { - return ( - - - - ); - } - - if (action === CONST.SEARCH.ACTION_TYPES.VIEW || shouldUseViewAction || isChildListItem) { - const buttonInnerStyles = isSelected ? styles.buttonDefaultSelected : {}; - - return isLargeScreenWidth ? ( -