From c79537c10ae70135cea6ff8f6fd74444c21bf0d5 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Thu, 8 Jan 2026 15:42:50 -0500 Subject: [PATCH 1/2] Revert "Merge pull request #79085 from Expensify/alberto-cpDist" This reverts commit 63b38574a9727d79e4006faeeecb27e8705ebb51, reversing changes made to 883e8ec97c0131519e186ccc21b729d63e861692. --- .../iou/request/step/IOURequestStepParticipants.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 686238bbb3fd1..19cea9d26ba51 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -21,7 +21,7 @@ import {isPaidGroupPolicy} from '@libs/PolicyUtils'; import {findSelfDMReportID, generateReportID, isInvoiceRoomWithID} from '@libs/ReportUtils'; import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; import {endSpan} from '@libs/telemetry/activeSpans'; -import {getRequestType, hasRoute, isCorporateCardTransaction, isDistanceRequest, isPerDiemRequest} from '@libs/TransactionUtils'; +import {getRequestType, isCorporateCardTransaction, isPerDiemRequest} from '@libs/TransactionUtils'; import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyRequestParticipantsSelector'; import { navigateToStartStepIfScanFileCannotBeRead, @@ -412,16 +412,8 @@ function IOURequestStepParticipants({ }, [isFocused, action]); const isWorkspacesOnly = useMemo(() => { - if (isDistanceRequest(initialTransaction)) { - // For distance requests, only restrict to workspaces if a route exists and the distance is 0 - // If no route exists yet, the distance hasn't been calculated and we should allow P2P - if (!hasRoute(initialTransaction, true)) { - return false; - } - return initialTransaction?.comment?.customUnit?.quantity === 0; - } return initialTransaction?.amount !== undefined && initialTransaction?.amount !== null && initialTransaction?.amount <= 0; - }, [initialTransaction]); + }, [initialTransaction?.amount]); return ( Date: Thu, 8 Jan 2026 15:43:25 -0500 Subject: [PATCH 2/2] Revert "Merge pull request #77238 from Expensify/alberto-zeroV4" This reverts commit 454e537e33b774c53e5aeacb5452328c9b336b78, reversing changes made to 501451268db53cb1290507268f411bd89ae217fe. --- __mocks__/reportData/transactions.ts | 4 +- src/CONST/index.ts | 1 - src/components/MoneyReportHeader.tsx | 1 - .../MoneyRequestConfirmationList.tsx | 7 +-- src/components/ProcessMoneyReportHoldMenu.tsx | 12 ++-- .../MoneyRequestReportPreview/index.tsx | 2 +- .../ReportActionItem/MoneyRequestView.tsx | 20 +++---- .../TransactionPreview/index.tsx | 2 +- src/components/Search/index.tsx | 11 ++-- src/components/TransactionItemRow/index.tsx | 2 +- src/libs/API/parameters/TrackExpenseParams.ts | 1 - src/libs/DistanceRequestUtils.ts | 6 +- src/libs/ModifiedExpenseMessage.ts | 8 +-- src/libs/ReportUtils.ts | 11 ++-- src/libs/SearchUIUtils.ts | 8 +-- src/libs/TransactionPreviewUtils.ts | 8 ++- src/libs/TransactionUtils/index.ts | 55 ++++--------------- src/libs/Violations/ViolationsUtils.ts | 4 +- src/libs/actions/IOU/index.ts | 9 +-- src/libs/actions/Policy/Member.ts | 1 - src/libs/actions/Policy/Policy.ts | 4 +- src/libs/actions/Report.ts | 4 +- src/pages/AddUnreportedExpense.tsx | 2 +- src/pages/iou/MoneyRequestAmountForm.tsx | 32 +---------- src/pages/iou/SplitBillDetailsPage.tsx | 2 +- .../iou/request/step/IOURequestStepAmount.tsx | 1 - .../step/IOURequestStepConfirmation.tsx | 3 +- .../step/IOURequestStepDistanceManual.tsx | 17 +----- .../request/step/IOURequestStepMerchant.tsx | 7 +-- .../step/IOURequestStepParticipants.tsx | 2 +- src/stories/objects/Transaction.ts | 2 +- src/types/onyx/Transaction.ts | 2 +- tests/actions/IOUTest.ts | 17 +++--- tests/actions/ReportPreviewActionUtilsTest.ts | 12 ---- tests/unit/AddUnreportedExpenseSearchTest.ts | 2 +- tests/unit/DebugUtilsTest.ts | 15 ++--- tests/unit/ModifiedExpenseMessageTest.ts | 4 +- tests/unit/ReportUtilsTest.ts | 6 +- tests/unit/Search/SearchUIUtilsTest.ts | 48 ++++++++-------- .../Search/handleActionButtonPressTest.ts | 4 +- tests/unit/TransactionPreviewUtils.test.ts | 15 ++--- tests/unit/TransactionUtilsTest.ts | 3 +- tests/utils/collections/transaction.ts | 2 +- 43 files changed, 129 insertions(+), 250 deletions(-) diff --git a/__mocks__/reportData/transactions.ts b/__mocks__/reportData/transactions.ts index a1f35834450e4..fcc112778fc0c 100644 --- a/__mocks__/reportData/transactions.ts +++ b/__mocks__/reportData/transactions.ts @@ -30,7 +30,7 @@ const transactionR14932: Transaction = { reimbursable: true, hasEReceipt: true, cardID: 0, - modifiedAmount: '', + modifiedAmount: 0, originalAmount: 0, comment: {}, bank: '', @@ -59,7 +59,7 @@ const transactionR98765: Transaction = { hasEReceipt: true, managedCard: false, billable: false, - modifiedAmount: '', + modifiedAmount: 0, cardID: 0, originalAmount: 0, comment: {}, diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 3098f434f6c49..268b664b6af0b 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -729,7 +729,6 @@ const CONST = { NO_OPTIMISTIC_TRANSACTION_THREADS: 'noOptimisticTransactionThreads', UBER_FOR_BUSINESS: 'uberForBusiness', CUSTOM_REPORT_NAMES: 'newExpensifyCustomReportNames', - ZERO_EXPENSES: 'zeroExpenses', NEW_DOT_DEW: 'newDotDEW', GPS_MILEAGE: 'gpsMileage', }, diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 0751d9a2e57b2..40b95ae223787 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -1741,7 +1741,6 @@ function MoneyReportHeader({ paymentType={paymentType} chatReport={chatReport} moneyRequestReport={moneyRequestReport} - hasNonHeldExpenses={!hasOnlyHeldExpenses} startAnimation={() => { if (requestType === CONST.IOU.REPORT_ACTION_TYPE.APPROVE) { startApprovedAnimation(); diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 76c09481b5d86..3039556287397 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -544,12 +544,9 @@ function MoneyRequestConfirmationList({ if (iouAmount !== 0) { text = translate('iou.createExpenseWithAmount', {amount: formattedAmount}); } - } else if (isTypeSplit) { - text = translate('iou.splitAmount', {amount: formattedAmount}); - } else if (iouAmount === 0) { - text = translate('iou.createExpense'); } else { - text = translate('iou.createExpenseWithAmount', {amount: formattedAmount}); + const translationKey = isTypeSplit ? 'iou.splitAmount' : 'iou.createExpenseWithAmount'; + text = translate(translationKey, {amount: formattedAmount}); } return [ { diff --git a/src/components/ProcessMoneyReportHoldMenu.tsx b/src/components/ProcessMoneyReportHoldMenu.tsx index aa21dce5eef44..c34f11928ddca 100644 --- a/src/components/ProcessMoneyReportHoldMenu.tsx +++ b/src/components/ProcessMoneyReportHoldMenu.tsx @@ -47,14 +47,11 @@ type ProcessMoneyReportHoldMenuProps = { /** Callback for displaying payment animation on IOU preview component */ startAnimation?: () => void; - - /** Whether the report has non held expenses */ - hasNonHeldExpenses?: boolean; }; function ProcessMoneyReportHoldMenu({ requestType, - nonHeldAmount = '0', + nonHeldAmount, fullAmount, onClose, isVisible, @@ -63,7 +60,6 @@ function ProcessMoneyReportHoldMenu({ moneyRequestReport, transactionCount, startAnimation, - hasNonHeldExpenses, }: ProcessMoneyReportHoldMenuProps) { const {translate} = useLocalize(); const isApprove = requestType === CONST.IOU.REPORT_ACTION_TYPE.APPROVE; @@ -106,11 +102,11 @@ function ProcessMoneyReportHoldMenu({ }; const promptText = useMemo(() => { - if (hasNonHeldExpenses) { + if (nonHeldAmount) { return translate(isApprove ? 'iou.confirmApprovalAmount' : 'iou.confirmPayAmount'); } return translate(isApprove ? 'iou.confirmApprovalAllHoldAmount' : 'iou.confirmPayAllHoldAmount', {count: transactionCount}); - }, [hasNonHeldExpenses, transactionCount, translate, isApprove]); + }, [nonHeldAmount, transactionCount, translate, isApprove]); return ( onSubmit(false)} onSecondOptionSubmit={() => onSubmit(true)} diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx index 973df12bc9189..3de2093e0fb32 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx @@ -96,7 +96,7 @@ function MoneyRequestReportPreview({ } // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - return transactions.some((transaction) => (Number(transaction?.modifiedAmount) || transaction?.amount) < 0); + return transactions.some((transaction) => (transaction?.modifiedAmount || transaction?.amount) < 0); }, [transactions, action.childType, iouReport]); const openReportFromPreview = useCallback(() => { diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 56c41e036a7b7..2a86575969426 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -238,7 +238,6 @@ function MoneyRequestView({ const currentUserEmailParam = currentUserPersonalDetails.login ?? ''; const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); - const isZeroExpensesBetaEnabled = isBetaEnabled(CONST.BETAS.ZERO_EXPENSES); const moneyRequestReport = parentReport; const isApproved = isReportApproved({report: moneyRequestReport}); @@ -273,9 +272,7 @@ function MoneyRequestView({ originalCurrency: transactionOriginalCurrency, postedDate: transactionPostedDate, } = getTransactionDetails(transaction, undefined, undefined, allowNegativeAmount, false, currentUserPersonalDetails) ?? {}; - const isZeroTransactionAmount = transactionAmount === 0; - const isEmptyMerchant = - transactionMerchant === '' || transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transactionMerchant === CONST.TRANSACTION.DEFAULT_MERCHANT; + const isEmptyMerchant = transactionMerchant === '' || transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; const isDistanceRequest = isDistanceRequestTransactionUtils(transaction); const isManualDistanceRequest = isManualDistanceRequestTransactionUtils(transaction, !!mergeTransactionID); const isMapDistanceRequest = isDistanceRequest && !isManualDistanceRequest; @@ -287,10 +284,9 @@ function MoneyRequestView({ // Use the updated transaction amount in merge flow to have correct positive/negative sign const actualAmount = isFromMergeTransaction && updatedTransaction ? updatedTransaction.amount : transactionAmount; const actualCurrency = updatedTransaction ? getCurrency(updatedTransaction) : transactionCurrency; - const shouldDisplayTransactionAmount = (isDistanceRequest && hasRoute) || !isDistanceRequest; + const shouldDisplayTransactionAmount = ((isDistanceRequest && hasRoute) || !!actualAmount) && actualAmount !== undefined; const formattedTransactionAmount = shouldDisplayTransactionAmount ? convertToDisplayString(actualAmount, actualCurrency) : ''; - const formattedPerAttendeeAmount = - shouldDisplayTransactionAmount && actualAmount !== undefined ? convertToDisplayString(actualAmount / (transactionAttendees?.length ?? 1), actualCurrency) : ''; + const formattedPerAttendeeAmount = shouldDisplayTransactionAmount ? convertToDisplayString(actualAmount / (actualAttendees?.length ?? 1), actualCurrency) : ''; const transactionOriginalAmount = transaction && getOriginalAmountForDisplay(transaction, isExpenseReport(moneyRequestReport)); const formattedOriginalAmount = transactionOriginalAmount && transactionOriginalCurrency && convertToDisplayString(transactionOriginalAmount, transactionOriginalCurrency); @@ -396,18 +392,16 @@ function MoneyRequestView({ let rateToDisplay = isCustomUnitOutOfPolicy ? translate('common.rateOutOfPolicy') : DistanceRequestUtils.getRateForDisplay(unit, rate, currency, translate, toLocaleDigit, isOffline); const distanceToDisplay = DistanceRequestUtils.getDistanceForDisplay(hasRoute, distance, unit, rate, translate); let merchantTitle = isEmptyMerchant ? '' : transactionMerchant; - let amountTitle = formattedTransactionAmount?.toString() || ''; + let amountTitle = formattedTransactionAmount ? formattedTransactionAmount.toString() : ''; if (isTransactionScanning) { merchantTitle = translate('iou.receiptStatusTitle'); amountTitle = translate('iou.receiptStatusTitle'); } const shouldNavigateToUpgradePath = !policyForMovingExpenses && !shouldSelectPolicy; + const updatedTransactionDescription = getDescription(updatedTransaction) || undefined; - const isEmptyUpdatedMerchant = - updatedTransaction?.modifiedMerchant === '' || - updatedTransaction?.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || - updatedTransaction?.modifiedMerchant === CONST.TRANSACTION.DEFAULT_MERCHANT; + const isEmptyUpdatedMerchant = updatedTransaction?.modifiedMerchant === '' || updatedTransaction?.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; const updatedMerchantTitle = isEmptyUpdatedMerchant ? '' : (updatedTransaction?.modifiedMerchant ?? merchantTitle); const saveBillable = (newBillable: boolean) => { @@ -483,7 +477,7 @@ function MoneyRequestView({ // NOTE: receipt field can return multiple violations, so we need to handle it separately const fieldChecks: Partial> = { amount: { - isError: isZeroTransactionAmount && !isZeroExpensesBetaEnabled, + isError: transactionAmount === 0, translationPath: canEditAmount ? 'common.error.enterAmount' : 'common.error.missingAmount', }, merchant: { diff --git a/src/components/ReportActionItem/TransactionPreview/index.tsx b/src/components/ReportActionItem/TransactionPreview/index.tsx index 782af0b9a7953..5a50a494d99ad 100644 --- a/src/components/ReportActionItem/TransactionPreview/index.tsx +++ b/src/components/ReportActionItem/TransactionPreview/index.tsx @@ -93,7 +93,7 @@ function TransactionPreview(props: TransactionPreviewProps) { // See description of `transactionRawAmount` prop for more context // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const transactionRawAmount = (Number(transaction?.modifiedAmount) || transaction?.amount) ?? 0; + const transactionRawAmount = (transaction?.modifiedAmount || transaction?.amount) ?? 0; const shouldDisableOnPress = isBillSplit && isEmptyObject(transaction); const isTransactionMadeWithCard = isManagedCardTransaction(transaction); diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 4e7371421edb5..38d726b7bf7c0 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -58,7 +58,7 @@ import { shouldShowYear as shouldShowYearUtil, } from '@libs/SearchUIUtils'; import {cancelSpan, endSpan, startSpan} from '@libs/telemetry/activeSpans'; -import {getOriginalTransactionWithSplitInfo, hasValidModifiedAmount, isOnHold, isTransactionPendingDelete, mergeProhibitedViolations, shouldShowViolation} from '@libs/TransactionUtils'; +import {getOriginalTransactionWithSplitInfo, isOnHold, isTransactionPendingDelete, mergeProhibitedViolations, shouldShowViolation} from '@libs/TransactionUtils'; import Navigation, {navigationRef} from '@navigation/Navigation'; import type {SearchFullscreenNavigatorParamList} from '@navigation/types'; import EmptySearchView from '@pages/Search/EmptySearchView'; @@ -126,7 +126,7 @@ function mapTransactionItemToSelectedEntry( groupExchangeRate: item.groupExchangeRate, reportID: item.reportID, policyID: item.report?.policyID, - amount: hasValidModifiedAmount(item) ? Number(item.modifiedAmount) : item.amount, + amount: item.modifiedAmount ?? item.amount, groupAmount: item.groupAmount, currency: item.currency, isFromOneTransactionReport: isOneTransactionReport(item.report), @@ -176,7 +176,8 @@ function prepareTransactionsList( action: item.action, reportID: item.reportID, policyID: item.policyID, - amount: Math.abs(hasValidModifiedAmount(item) ? Number(item.modifiedAmount) : item.amount), + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + amount: Math.abs(item.modifiedAmount || item.amount), groupAmount: item.groupAmount, groupCurrency: item.groupCurrency, groupExchangeRate: item.groupExchangeRate, @@ -536,7 +537,7 @@ function Search({ canReject: canRejectRequest, reportID: transactionItem.reportID, policyID: transactionItem.report?.policyID, - amount: hasValidModifiedAmount(transactionItem) ? Number(transactionItem.modifiedAmount) : transactionItem.amount, + amount: transactionItem.modifiedAmount ?? transactionItem.amount, groupAmount: transactionItem.groupAmount, groupCurrency: transactionItem.groupCurrency, groupExchangeRate: transactionItem.groupExchangeRate, @@ -589,7 +590,7 @@ function Search({ canReject: canRejectRequest, reportID: transactionItem.reportID, policyID: transactionItem.report?.policyID, - amount: hasValidModifiedAmount(transactionItem) ? Number(transactionItem.modifiedAmount) : transactionItem.amount, + amount: transactionItem.modifiedAmount ?? transactionItem.amount, groupAmount: transactionItem.groupAmount, groupCurrency: transactionItem.groupCurrency, groupExchangeRate: transactionItem.groupExchangeRate, diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 31b49735fa4d9..b20e544fa1de1 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -144,7 +144,7 @@ function getMerchantName(transactionItem: TransactionWithOptionalSearchFields, t } const merchantName = StringUtils.getFirstLine(merchant); - return merchantName !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && merchantName !== CONST.TRANSACTION.DEFAULT_MERCHANT ? merchantName : ''; + return merchantName !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? merchantName : ''; } function TransactionItemRow({ diff --git a/src/libs/API/parameters/TrackExpenseParams.ts b/src/libs/API/parameters/TrackExpenseParams.ts index 7cf42fd2e36eb..9b653d5a2a3c3 100644 --- a/src/libs/API/parameters/TrackExpenseParams.ts +++ b/src/libs/API/parameters/TrackExpenseParams.ts @@ -35,7 +35,6 @@ type TrackExpenseParams = { customUnitRateID?: string; description?: string; distance?: number; - isDistance?: boolean; }; export default TrackExpenseParams; diff --git a/src/libs/DistanceRequestUtils.ts b/src/libs/DistanceRequestUtils.ts index 4c3970061d106..1a3f1b119e73f 100644 --- a/src/libs/DistanceRequestUtils.ts +++ b/src/libs/DistanceRequestUtils.ts @@ -6,8 +6,6 @@ import type {Unit} from '@src/types/onyx/Policy'; import type Policy from '@src/types/onyx/Policy'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import {getCurrencySymbol} from './CurrencyUtils'; -// This will be fixed as part of https://github.com/Expensify/App/issues/66397 -// eslint-disable-next-line @typescript-eslint/no-deprecated import {getDistanceRateCustomUnit, getDistanceRateCustomUnitRate, getPersonalPolicy, getUnitRateValue} from './PolicyUtils'; import {getCurrency, getRateID, isCustomUnitRateIDForP2P} from './TransactionUtils'; @@ -177,7 +175,7 @@ function getDistanceForDisplay( translate: LocaleContextProps['translate'], useShortFormUnit?: boolean, ): string { - if (!hasRoute || !unit) { + if (!hasRoute || !unit || !distanceInMeters) { return translate('iou.fieldPending'); } @@ -371,8 +369,6 @@ function getRate({ if (isEmptyObject(mileageRates) && policyDraft) { mileageRates = getMileageRates(policyDraft, true, transaction?.comment?.customUnit?.customUnitRateID); } - // This will be fixed as part of https://github.com/Expensify/App/issues/66397 - // eslint-disable-next-line @typescript-eslint/no-deprecated const policyCurrency = policy?.outputCurrency ?? getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; const defaultMileageRate = getDefaultMileageRate(policy); const customUnitRateID = getRateID(transaction); diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index ba2fa1d674bee..11ec215363b53 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -246,7 +246,7 @@ function getForReportAction({ if (hasModifiedAmount) { const oldCurrency = reportActionOriginalMessage?.oldCurrency; const oldAmountValue = reportActionOriginalMessage?.oldAmount ?? 0; - const oldAmount = convertToDisplayString(oldAmountValue, oldCurrency); + const oldAmount = oldAmountValue ? convertToDisplayString(reportActionOriginalMessage?.oldAmount ?? 0, oldCurrency) : ''; const currency = reportActionOriginalMessage?.currency; const amount = convertToDisplayString(reportActionOriginalMessage?.amount ?? 0, currency); @@ -397,7 +397,7 @@ function getForReportAction({ const taxAmount = convertToDisplayString(getTaxAmountAbsValue(reportActionOriginalMessage?.taxAmount ?? 0), currency); const oldTaxAmountValue = getTaxAmountAbsValue(reportActionOriginalMessage?.oldTaxAmount ?? 0); - const oldTaxAmount = convertToDisplayString(oldTaxAmountValue, currency); + const oldTaxAmount = oldTaxAmountValue > 0 ? convertToDisplayString(oldTaxAmountValue, currency) : ''; // eslint-disable-next-line @typescript-eslint/no-deprecated buildMessageFragmentForValue(translateLocal, taxAmount, oldTaxAmount, translateLocal('iou.taxAmount'), false, setFragments, removalFragments, changeFragments); } @@ -536,7 +536,7 @@ function getForReportActionTemp({ if (hasModifiedAmount) { const oldCurrency = reportActionOriginalMessage?.oldCurrency; const oldAmountValue = reportActionOriginalMessage?.oldAmount ?? 0; - const oldAmount = convertToDisplayString(oldAmountValue, oldCurrency); + const oldAmount = oldAmountValue ? convertToDisplayString(reportActionOriginalMessage?.oldAmount ?? 0, oldCurrency) : ''; const currency = reportActionOriginalMessage?.currency; const amount = convertToDisplayString(reportActionOriginalMessage?.amount ?? 0, currency); @@ -659,7 +659,7 @@ function getForReportActionTemp({ const taxAmount = convertToDisplayString(getTaxAmountAbsValue(reportActionOriginalMessage?.taxAmount ?? 0), currency); const oldTaxAmountValue = getTaxAmountAbsValue(reportActionOriginalMessage?.oldTaxAmount ?? 0); - const oldTaxAmount = convertToDisplayString(oldTaxAmountValue, currency); + const oldTaxAmount = oldTaxAmountValue > 0 ? convertToDisplayString(oldTaxAmountValue, currency) : ''; buildMessageFragmentForValue(translate, taxAmount, oldTaxAmount, translate('iou.taxAmount'), false, setFragments, removalFragments, changeFragments); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 14b3b0da57911..b03046c423c3a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5371,7 +5371,7 @@ function getModifiedExpenseOriginalMessage( originalMessage.oldMerchant = getMerchant(oldTransaction); // For the originalMessage, we should use the non-negative amount, similar to what getAmount does for oldAmount - originalMessage.amount = Math.abs(Number(updatedTransaction?.modifiedAmount ?? 0)); + originalMessage.amount = Math.abs(updatedTransaction?.modifiedAmount ?? 0); originalMessage.currency = updatedTransaction?.modifiedCurrency ?? CONST.CURRENCY.USD; originalMessage.merchant = updatedTransaction?.modifiedMerchant; } @@ -10635,10 +10635,10 @@ function getNonHeldAndFullAmount(iouReport: OnyxEntry, shouldExcludeNonR const adjustedTotal = total * coefficient; // For the "approve unheld" option to be valid, we need: - // 1. There should be held expenses + // 1. There should be held expenses (unheld amount != total amount) // 2. For expense reports with negative totals, we need to ensure the unheld amount is valid // by checking that the absolute values are meaningful and different - const hasHeldExpensesLocal = hasHeldExpenses(iouReport?.reportID); + const hasHeldExpensesLocal = unheldTotal !== total; const hasValidNonHeldAmount = hasHeldExpensesLocal && // For normal cases (positive amounts or IOU reports) @@ -12244,10 +12244,7 @@ function hasExportError(reportActions: OnyxEntry | ReportAction[] function doesReportContainRequestsFromMultipleUsers(iouReport: OnyxEntry): boolean { const transactions = getReportTransactions(iouReport?.reportID); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (Permissions.isBetaEnabled(CONST.BETAS.ZERO_EXPENSES, allBetas)) { - return isIOUReport(iouReport) && transactions.some((transaction) => (Number(transaction?.modifiedAmount) || transaction?.amount) <= 0); - } - return isIOUReport(iouReport) && transactions.some((transaction) => (Number(transaction?.modifiedAmount) || transaction?.amount) < 0); + return isIOUReport(iouReport) && transactions.some((transaction) => (transaction?.modifiedAmount || transaction?.amount) < 0); } /** diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 8bc8ed0bc624b..1a003d3339790 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -751,7 +751,7 @@ function getTransactionItemCommonFormattedProperties( const formattedTotal = getTransactionAmount(transactionItem, isExpenseReport); const date = transactionItem?.modifiedCreated ? transactionItem.modifiedCreated : transactionItem?.created; const merchant = getTransactionMerchant(transactionItem, policy); - const formattedMerchant = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || merchant === CONST.TRANSACTION.DEFAULT_MERCHANT ? '' : merchant; + const formattedMerchant = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? '' : merchant; const submitted = report?.submitted; const approved = report?.approved; @@ -817,7 +817,7 @@ function getShouldShowMerchant(data: OnyxTypes.SearchResults['data']): boolean { if (isTransactionEntry(key)) { const item = data[key]; const merchant = item.modifiedMerchant ? item.modifiedMerchant : (item.merchant ?? ''); - return merchant !== '' && merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && merchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; + return merchant !== '' && merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; } return false; }); @@ -887,7 +887,7 @@ function isAmountTooLong(amount: number, maxLength = 8): boolean { function isTransactionAmountTooLong(transactionItem: TransactionListItemType | OnyxTypes.Transaction) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const amount = Math.abs(Number(transactionItem.modifiedAmount) || transactionItem.amount); + const amount = Math.abs(transactionItem.modifiedAmount || transactionItem.amount); return isAmountTooLong(amount); } @@ -3261,7 +3261,7 @@ function getColumnsToShow( const {moneyRequestReportActionsByTransactionID} = Array.isArray(data) ? {} : createReportActionsLookupMaps(data); const updateColumns = (transaction: OnyxTypes.Transaction) => { const merchant = transaction.modifiedMerchant ? transaction.modifiedMerchant : (transaction.merchant ?? ''); - if ((merchant !== '' && merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && merchant !== CONST.TRANSACTION.DEFAULT_MERCHANT) || isScanning(transaction)) { + if ((merchant !== '' && merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT) || isScanning(transaction)) { columns[CONST.SEARCH.TABLE_COLUMNS.MERCHANT] = true; } diff --git a/src/libs/TransactionPreviewUtils.ts b/src/libs/TransactionPreviewUtils.ts index 58106ca75ed58..6362f15576f61 100644 --- a/src/libs/TransactionPreviewUtils.ts +++ b/src/libs/TransactionPreviewUtils.ts @@ -33,6 +33,7 @@ import { hasPendingRTERViolation, hasViolation, hasWarningTypeViolation, + isAmountMissing, isCreatedMissing, isDistanceRequest, isFetchingWaypointsFromServer, @@ -258,7 +259,12 @@ function getTransactionPreviewTextAndTranslationPaths({ if (hasFieldErrors && RBRMessage === undefined) { const merchantMissing = isMerchantMissing(transaction); - if (merchantMissing) { + const amountMissing = isAmountMissing(transaction); + if (amountMissing && merchantMissing) { + RBRMessage = {translationPath: 'violations.reviewRequired'}; + } else if (amountMissing) { + RBRMessage = {translationPath: 'iou.missingAmount'}; + } else if (merchantMissing) { RBRMessage = {translationPath: 'iou.missingMerchant'}; } } diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 62213616a4407..ead7dd0175af0 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -21,7 +21,6 @@ import {toLocaleDigit} from '@libs/LocaleDigitUtils'; import {translateLocal} from '@libs/Localize'; import Log from '@libs/Log'; import {rand64, roundToTwoDecimalPlaces} from '@libs/NumberUtils'; -import Permissions from '@libs/Permissions'; import {getLoginsByAccountIDs, getPersonalDetailsByIDs} from '@libs/PersonalDetailsUtils'; import { getCommaSeparatedTagNameWithSanitizedColons, @@ -54,7 +53,6 @@ import type {IOUType} from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; import ONYXKEYS from '@src/ONYXKEYS'; import type { - Beta, CardList, OnyxInputOrEntry, Policy, @@ -125,12 +123,6 @@ type BuildOptimisticTransactionParams = { isDemoTransactionParam?: boolean; }; -let allBetas: OnyxEntry; -Onyx.connectWithoutView({ - key: ONYXKEYS.BETAS, - callback: (value) => (allBetas = value), -}); - let deprecatedAllReports: OnyxCollection = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, @@ -147,7 +139,7 @@ Onyx.connect({ callback: (value) => (deprecatedAllTransactionViolations = value), }); -function hasDistanceCustomUnit(transaction: OnyxEntry | Partial): boolean { +function hasDistanceCustomUnit(transaction: OnyxEntry): boolean { const type = transaction?.comment?.type; const customUnitName = transaction?.comment?.customUnit?.name; return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_DISTANCE; @@ -203,11 +195,6 @@ function isScanRequest(transaction: OnyxEntry | Partial): boolean function isMerchantMissing(transaction: OnyxEntry) { if (transaction?.modifiedMerchant && transaction.modifiedMerchant !== '') { - return transaction.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction.modifiedMerchant === CONST.TRANSACTION.DEFAULT_MERCHANT; + return transaction.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; } - const isMerchantEmpty = - transaction?.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction?.merchant === CONST.TRANSACTION.DEFAULT_MERCHANT || transaction?.merchant === ''; + const isMerchantEmpty = transaction?.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction?.merchant === ''; return isMerchantEmpty; } @@ -497,20 +481,7 @@ function isPartialMerchant(merchant: string): boolean { } function isAmountMissing(transaction: OnyxEntry) { - if (Permissions.isBetaEnabled(CONST.BETAS.ZERO_EXPENSES, allBetas)) { - return transaction?.amount === undefined && (!transaction?.modifiedAmount === undefined || transaction?.modifiedAmount === ''); - } - return (transaction?.amount === 0 || transaction?.amount === undefined) && (!transaction?.modifiedAmount || transaction?.modifiedAmount === 0 || transaction?.modifiedAmount === ''); -} - -function hasValidModifiedAmount(transaction: OnyxEntry | null): boolean { - if (!transaction) { - return false; - } - if (Permissions.isBetaEnabled(CONST.BETAS.ZERO_EXPENSES, allBetas)) { - return transaction?.modifiedAmount !== undefined && transaction?.modifiedAmount !== null && transaction?.modifiedAmount !== ''; - } - return transaction?.modifiedAmount !== undefined && transaction?.modifiedAmount !== null && transaction?.modifiedAmount !== '' && transaction?.modifiedAmount !== 0; + return transaction?.amount === 0 && (!transaction.modifiedAmount || transaction.modifiedAmount === 0); } function isPartial(transaction: OnyxEntry): boolean { @@ -531,9 +502,6 @@ function areRequiredFieldsEmpty(transaction: OnyxEntry, reportTrans (participant) => deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.chatReportID}`]?.isOwnPolicyExpenseChat, ); const isMerchantRequired = isFromExpenseReport || isSplitPolicyExpenseChat; - if (Permissions.isBetaEnabled(CONST.BETAS.ZERO_EXPENSES, allBetas)) { - return (isMerchantRequired && isMerchantMissing(transaction)) || isCreatedMissing(transaction); - } return (isMerchantRequired && isMerchantMissing(transaction)) || isAmountMissing(transaction) || isCreatedMissing(transaction); } @@ -790,8 +758,8 @@ function getDescription(transaction: OnyxInputOrEntry): string { function getAmount(transaction: OnyxInputOrEntry, isFromExpenseReport = false, isFromTrackedExpense = false, allowNegative = false, disableOppositeConversion = false): number { // IOU requests cannot have negative values, but they can be stored as negative values, let's return absolute value if (!isFromExpenseReport && !isFromTrackedExpense && !allowNegative) { - const amount = Number(transaction?.modifiedAmount) ?? 0; - if (hasValidModifiedAmount(transaction)) { + const amount = transaction?.modifiedAmount ?? 0; + if (amount) { return Math.abs(amount); } return Math.abs(transaction?.amount ?? 0); @@ -804,8 +772,8 @@ function getAmount(transaction: OnyxInputOrEntry, isFromExpenseRepo // Expense report case: // The amounts are stored using an opposite sign and negative values can be set, // we need to return an opposite sign than is saved in the transaction object - let amount = Number(transaction?.modifiedAmount) ?? 0; - if (hasValidModifiedAmount(transaction)) { + let amount = transaction?.modifiedAmount ?? 0; + if (amount) { return -amount; } @@ -909,9 +877,9 @@ function getOriginalAmount(transaction: Transaction): number { function getOriginalAmountForDisplay(transaction: Pick, isExpenseReport: boolean): number { /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ if (isExpenseReport) { - return -((transaction.originalAmount || transaction.amount || Number(transaction.modifiedAmount)) ?? 0); + return -((transaction.originalAmount || transaction.amount || transaction.modifiedAmount) ?? 0); } - return getOriginalAmount(transaction as Transaction) || Math.abs(transaction.amount ?? 0) || Math.abs(Number(transaction.modifiedAmount ?? 0)); + return getOriginalAmount(transaction as Transaction) || Math.abs(transaction.amount ?? 0) || Math.abs(transaction.modifiedAmount ?? 0); /* eslint-enable @typescript-eslint/prefer-nullish-coalescing */ } @@ -2566,7 +2534,6 @@ export { areRequiredFieldsEmpty, hasMissingSmartscanFields, hasPendingRTERViolation, - hasValidModifiedAmount, allHavePendingRTERViolation, hasPendingUI, getWaypointIndex, diff --git a/src/libs/Violations/ViolationsUtils.ts b/src/libs/Violations/ViolationsUtils.ts index a0dfc64da7025..a09cc8165d7ae 100644 --- a/src/libs/Violations/ViolationsUtils.ts +++ b/src/libs/Violations/ViolationsUtils.ts @@ -12,7 +12,7 @@ import Parser from '@libs/Parser'; import {getDistanceRateCustomUnitRate, getPerDiemRateCustomUnitRate, getSortedTagKeys, isDefaultTagName, isTaxTrackingEnabled} from '@libs/PolicyUtils'; import {isCurrentUserSubmitter} from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; -import {hasValidModifiedAmount, isViolationDismissed, shouldShowViolation} from '@libs/TransactionUtils'; +import {isViolationDismissed, shouldShowViolation} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, PolicyCategories, PolicyTagLists, Report, ReportAction, Transaction, TransactionViolation, ViolationName} from '@src/types/onyx'; @@ -344,7 +344,7 @@ const ViolationsUtils = { const isTaxInPolicy = Object.keys(policy.taxRates?.taxes ?? {}).some((key) => key === updatedTransaction.taxCode); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const amount = hasValidModifiedAmount(updatedTransaction) ? Number(updatedTransaction.modifiedAmount) : updatedTransaction.amount; + const amount = updatedTransaction.modifiedAmount || updatedTransaction.amount; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const currency = updatedTransaction.modifiedCurrency || updatedTransaction.currency; const canCalculateAmountViolations = policy.outputCurrency === currency; diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 746b3ad83c7b3..a1b36c5520946 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -1093,8 +1093,6 @@ function initMoneyRequest({ } } - const defaultMerchant = newIouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL ? CONST.TRANSACTION.DEFAULT_MERCHANT : CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; - const newTransaction = { amount: 0, comment, @@ -1105,7 +1103,7 @@ function initMoneyRequest({ reportID, transactionID: newTransactionID, isFromGlobalCreate, - merchant: defaultMerchant, + merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, }; // Store the transaction in Onyx and mark it as not saved so it can be cleaned up later @@ -6429,7 +6427,6 @@ function trackExpense(params: CreateTrackExpenseParams) { waypoints: sanitizedWaypoints, customUnitRateID, description: parsedComment, - isDistance: isMapDistanceRequest(transaction) || isManualDistanceRequestTransactionUtils(transaction), }; if (actionableWhisperReportActionIDParam) { parameters.actionableWhisperReportActionID = actionableWhisperReportActionIDParam; @@ -7753,7 +7750,7 @@ function completeSplitBill( ]; const splitParticipants: Split[] = updatedTransaction?.comment?.splits ?? []; - const amount = Number(updatedTransaction?.modifiedAmount); + const amount = updatedTransaction?.modifiedAmount; const currency = updatedTransaction?.modifiedCurrency; // Exclude the current user when calculating the split amount, `calculateAmount` takes it into account @@ -14202,7 +14199,7 @@ function updateSplitTransactions({ failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${firstIOU?.childReportID}`, - value: transactionThread ?? null, + value: transactionThread, }); } diff --git a/src/libs/actions/Policy/Member.ts b/src/libs/actions/Policy/Member.ts index b758efae0eec7..32d60f45a400a 100644 --- a/src/libs/actions/Policy/Member.ts +++ b/src/libs/actions/Policy/Member.ts @@ -896,7 +896,6 @@ function buildAddMembersToWorkspaceOnyxData( }; successMembersState[email] = {pendingAction: null}; failureMembersState[email] = { - pendingAction: null, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.people.error.genericAdd'), }; } diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index c8de3c4b164d7..fc4f9daab0c3c 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -89,7 +89,6 @@ import * as PhoneNumber from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import {getCustomUnitsForDuplication, getMemberAccountIDsForWorkspace, goBackWhenEnableFeature, isControlPolicy, navigateToExpensifyCardPage} from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; -import {hasValidModifiedAmount} from '@libs/TransactionUtils'; import type {PolicySelector} from '@pages/home/sidebar/FloatingActionButtonAndPopover'; import type {Feature} from '@pages/OnboardingInterestedFeatures/types'; import * as PaymentMethods from '@userActions/PaymentMethods'; @@ -451,7 +450,6 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { .filter((p) => p && p.id !== activePolicyID && p.type !== CONST.POLICY.TYPE.PERSONAL && p.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) .sort((policyA, policyB) => localeCompare(policyB?.created ?? '', policyA?.created ?? '')) .at(0); - const newActivePolicyID = mostRecentlyCreatedGroupPolicy?.id ?? personalPolicyID; // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 @@ -3763,7 +3761,7 @@ function createWorkspaceFromIOUPayment( transactionsOptimisticData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = { ...transaction, amount: -transaction.amount, - modifiedAmount: hasValidModifiedAmount(transaction) ? -Number(transaction.modifiedAmount) : '', + modifiedAmount: transaction.modifiedAmount ? -transaction.modifiedAmount : 0, }; transactionFailureData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = transaction; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 46a0b6accaa67..ec31412dfdff4 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -170,7 +170,7 @@ import { import {getCurrentSearchQueryJSON} from '@libs/SearchQueryUtils'; import type {ArchivedReportsIDSet} from '@libs/SearchUIUtils'; import playSound, {SOUNDS} from '@libs/Sound'; -import {getAmount, getCurrency, hasValidModifiedAmount, isOnHold, shouldClearConvertedAmount} from '@libs/TransactionUtils'; +import {getAmount, getCurrency, isOnHold, shouldClearConvertedAmount} from '@libs/TransactionUtils'; import addTrailingForwardSlash from '@libs/UrlUtils'; import Visibility from '@libs/Visibility'; import CONFIG from '@src/CONFIG'; @@ -5534,7 +5534,7 @@ function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, poli transactionsOptimisticData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = { ...transaction, amount: -transaction.amount, - modifiedAmount: hasValidModifiedAmount(transaction) ? -Number(transaction.modifiedAmount) : '', + modifiedAmount: transaction.modifiedAmount ? -transaction.modifiedAmount : 0, }; transactionFailureData[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`] = transaction; diff --git a/src/pages/AddUnreportedExpense.tsx b/src/pages/AddUnreportedExpense.tsx index d794556961961..a12588c2b4b32 100644 --- a/src/pages/AddUnreportedExpense.tsx +++ b/src/pages/AddUnreportedExpense.tsx @@ -131,7 +131,7 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) { const searchableFields: string[] = []; const merchant = getMerchant(transaction); - if (merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && merchant !== CONST.TRANSACTION.DEFAULT_MERCHANT) { + if (merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT) { searchableFields.push(merchant); } diff --git a/src/pages/iou/MoneyRequestAmountForm.tsx b/src/pages/iou/MoneyRequestAmountForm.tsx index 617ee7ecb894b..9bb0f505b92ee 100644 --- a/src/pages/iou/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/MoneyRequestAmountForm.tsx @@ -8,7 +8,6 @@ import type {NumberWithSymbolFormRef} from '@components/NumberWithSymbolForm'; import ScrollView from '@components/ScrollView'; import SettlementButton from '@components/SettlementButton'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import {convertToDisplayString, convertToFrontendAmountAsInteger, convertToFrontendAmountAsString} from '@libs/CurrencyUtils'; @@ -53,31 +52,9 @@ type MoneyRequestAmountFormProps = Omit>([CONST.IOU.TYPE.PAY, CONST.IOU.TYPE.INVOICE, CONST.IOU.TYPE.SPLIT]); -const isAmountInvalid = (amount: string, iouType: ValueOf, isP2P: boolean, isZeroAmountBetaEnabled: boolean) => { - if (!isZeroAmountBetaEnabled) { - return !amount.length || parseFloat(amount) < 0.01; - } - - if (!amount.length || parseFloat(amount) < 0) { - return true; - } - - if ((iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SUBMIT) && parseFloat(amount) < 0.01 && isP2P) { - return true; - } - - if (parseFloat(amount) < 0.01 && nonZeroExpenses.has(iouType)) { - return true; - } - - return false; -}; +const isAmountInvalid = (amount: string) => !amount.length || parseFloat(amount) < 0.01; const isTaxAmountInvalid = (currentAmount: string, taxAmount: number, isTaxAmountForm: boolean, currency: string) => isTaxAmountForm && Number.parseFloat(currentAmount) > convertToFrontendAmountAsInteger(Math.abs(taxAmount), currency); @@ -100,7 +77,6 @@ function MoneyRequestAmountForm({ chatReportID, hideCurrencySymbol = false, allowFlippingAmount = false, - isP2P = false, ref, }: MoneyRequestAmountFormProps) { const styles = useThemeStyles(); @@ -112,8 +88,6 @@ function MoneyRequestAmountForm({ const [isNegative, setIsNegative] = useState(false); - const {isBetaEnabled} = usePermissions(); - const [formError, setFormError] = useState(''); const formattedTaxAmount = convertToDisplayString(Math.abs(taxAmount), currency); @@ -169,7 +143,7 @@ function MoneyRequestAmountForm({ // Skip the check for tax amount form as 0 is a valid input const currentAmount = moneyRequestAmountInputRef.current?.getNumber() ?? ''; - if (!currentAmount.length || (!isTaxAmountForm && isAmountInvalid(currentAmount, iouType, isP2P, isBetaEnabled(CONST.BETAS.ZERO_EXPENSES)))) { + if (!currentAmount.length || (!isTaxAmountForm && isAmountInvalid(currentAmount))) { setFormError(translate('iou.error.invalidAmount')); return; } @@ -183,7 +157,7 @@ function MoneyRequestAmountForm({ onSubmitButtonPress({amount: newAmount, currency, paymentMethod: iouPaymentType}); }, - [taxAmount, currency, isNegative, onSubmitButtonPress, translate, formattedTaxAmount, iouType, isP2P, isBetaEnabled], + [taxAmount, currency, isNegative, onSubmitButtonPress, translate, formattedTaxAmount], ); const buttonText: string = useMemo(() => { diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index 746ceabf0cdce..53f4d4881e429 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -71,7 +71,7 @@ function SplitBillDetailsPage({route, report, reportAction}: SplitBillDetailsPag const hasSmartScanFailed = hasReceipt(transaction) && transaction?.receipt?.state === CONST.IOU.RECEIPT_STATE.SCAN_FAILED; const isDistanceRequest = isDistanceRequestUtil(transaction); - const isEditingSplitBill = session?.accountID === actorAccountID && (areRequiredFieldsEmpty(transaction) || transaction?.amount === 0) && !isDistanceRequest; + const isEditingSplitBill = session?.accountID === actorAccountID && areRequiredFieldsEmpty(transaction) && !isDistanceRequest; const isManualDistanceRequest = isManualDistanceRequestUtil(transaction); const isMapDistanceRequest = isDistanceRequest && !isManualDistanceRequest; const [isConfirmed, setIsConfirmed] = useState(false); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 5ceca46eb37a8..27523b2df5485 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -408,7 +408,6 @@ function IOURequestStepAmount({ allowFlippingAmount={!isSplitBill && allowNegative} selectedTab={iouRequestType as SelectedTabRequest} chatReportID={reportID} - isP2P={isParticipantP2P(getMoneyRequestParticipantsFromReport(report, currentUserPersonalDetails.accountID).at(0))} isCurrencyPressable={!isUnreportedDistanceExpense} /> diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 2458ceaad6b75..d21be6cca4839 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -1292,7 +1292,8 @@ function IOURequestStepConfirmation({ const showReceiptEmptyState = shouldShowReceiptEmptyState(iouType, action, policy, isPerDiemRequest); - const shouldShowSmartScanFields = !!transaction?.receipt?.isTestDriveReceipt || isMovingTransactionFromTrackExpense || requestType !== CONST.IOU.REQUEST_TYPE.SCAN; + const shouldShowSmartScanFields = + !!transaction?.receipt?.isTestDriveReceipt || (isMovingTransactionFromTrackExpense ? transaction?.amount !== 0 : requestType !== CONST.IOU.REQUEST_TYPE.SCAN); return ( { const value = numberFormRef.current?.getNumber() ?? ''; - const isP2P = isParticipantP2P(getMoneyRequestParticipantsFromReport(report, currentUserAccountIDParam).at(0)); - - if (isBetaEnabled(CONST.BETAS.ZERO_EXPENSES)) { - if (!value.length || parseFloat(value) < 0) { - setFormError(translate('iou.error.invalidDistance')); - return; - } - } else if (!value.length || parseFloat(value) <= 0) { - setFormError(translate('iou.error.invalidDistance')); - return; - } - - if ((iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SUBMIT) && parseFloat(value) === 0 && isP2P) { + if (!value.length || parseFloat(value) < 0.01) { setFormError(translate('iou.error.invalidDistance')); return; } navigateToNextPage(value); - }, [navigateToNextPage, translate, report, iouType, currentUserAccountIDParam, isBetaEnabled]); + }, [navigateToNextPage, translate]); useEffect(() => { if (isLoadingSelectedTab) { diff --git a/src/pages/iou/request/step/IOURequestStepMerchant.tsx b/src/pages/iou/request/step/IOURequestStepMerchant.tsx index 49b221cf4d707..b1a4465a9d7c0 100644 --- a/src/pages/iou/request/step/IOURequestStepMerchant.tsx +++ b/src/pages/iou/request/step/IOURequestStepMerchant.tsx @@ -54,7 +54,7 @@ function IOURequestStepMerchant({ // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value const isEditingSplitBill = iouType === CONST.IOU.TYPE.SPLIT && isEditing; const merchant = getTransactionDetails(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction)?.merchant; - const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || merchant === CONST.TRANSACTION.DEFAULT_MERCHANT; + const isEmptyMerchant = merchant === '' || merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; const initialMerchant = isEmptyMerchant ? '' : merchant; const [currentMerchant, setCurrentMerchant] = useState(initialMerchant); const [isSaved, setIsSaved] = useState(false); @@ -86,10 +86,7 @@ function IOURequestStepMerchant({ if (isMerchantRequired && !value.moneyRequestMerchant) { errors.moneyRequestMerchant = translate('common.error.fieldRequired'); - } else if ( - isMerchantRequired && - (value.moneyRequestMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || value.moneyRequestMerchant === CONST.TRANSACTION.DEFAULT_MERCHANT) - ) { + } else if (isMerchantRequired && value.moneyRequestMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT) { errors.moneyRequestMerchant = translate('iou.error.invalidMerchant'); } else if (!isValid) { errors.moneyRequestMerchant = translate('common.error.characterLimitExceedCounter', byteLength, CONST.MERCHANT_NAME_MAX_BYTES); diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 19cea9d26ba51..799448e84d38c 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -412,7 +412,7 @@ function IOURequestStepParticipants({ }, [isFocused, action]); const isWorkspacesOnly = useMemo(() => { - return initialTransaction?.amount !== undefined && initialTransaction?.amount !== null && initialTransaction?.amount <= 0; + return !!(initialTransaction?.amount && initialTransaction?.amount < 0); }, [initialTransaction?.amount]); return ( diff --git a/src/stories/objects/Transaction.ts b/src/stories/objects/Transaction.ts index 4da6bea094045..c8f08b5d3e7fd 100644 --- a/src/stories/objects/Transaction.ts +++ b/src/stories/objects/Transaction.ts @@ -20,7 +20,7 @@ const transaction: Transaction & {mcc: string; modifiedMCC: string} = { managedCard: false, mcc: '', merchant: "Mario's", - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMCC: '', diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 7daf58c9856af..8107427a7bd09 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -476,7 +476,7 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< merchant: string; /** The edited transaction amount */ - modifiedAmount?: number | string; + modifiedAmount?: number; /** The edited attendees list */ modifiedAttendees?: Attendee[]; diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index f10df3c133344..3e61c9de21ac8 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -1198,7 +1198,7 @@ describe('actions/IOU', () => { attendees: [], currency: CONST.CURRENCY.USD, created: '', - merchant: '(none)', + merchant: '', comment, }, shouldGenerateTransactionThreadReport: true, @@ -1517,7 +1517,7 @@ describe('actions/IOU', () => { expect(newTransaction?.reportID).toBe(iouReportID); expect(newTransaction?.amount).toBe(amount); expect(newTransaction?.comment?.comment).toBe(comment); - expect(newTransaction?.merchant).toBe(CONST.TRANSACTION.DEFAULT_MERCHANT); + expect(newTransaction?.merchant).toBe(CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT); expect(newTransaction?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); // The transactionID on the iou action should match the one from the transactions collection @@ -1696,7 +1696,7 @@ describe('actions/IOU', () => { expect(transaction?.reportID).toBe(iouReportID); expect(transaction?.amount).toBe(amount); expect(transaction?.comment?.comment).toBe(comment); - expect(transaction?.merchant).toBe(CONST.TRANSACTION.DEFAULT_MERCHANT); + expect(transaction?.merchant).toBe(CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT); expect(transaction?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); // The transactionID on the iou action should match the one from the transactions collection @@ -7451,7 +7451,7 @@ describe('actions/IOU', () => { ...createRandomTransaction(0), reportID, amount: 0, - modifiedAmount: '', + modifiedAmount: 0, receipt: { source: 'test', state: CONST.IOU.RECEIPT_STATE.SCANNING, @@ -7463,7 +7463,7 @@ describe('actions/IOU', () => { ...createRandomTransaction(1), reportID, amount: 0, - modifiedAmount: '', + modifiedAmount: 0, receipt: { source: 'test', state: CONST.IOU.RECEIPT_STATE.SCANNING, @@ -7513,7 +7513,7 @@ describe('actions/IOU', () => { ...createRandomTransaction(1), reportID, amount: 0, - modifiedAmount: '', + modifiedAmount: 0, receipt: { source: 'test', state: CONST.IOU.RECEIPT_STATE.SCANNING, @@ -7808,7 +7808,7 @@ describe('actions/IOU', () => { reportID: fakeReport.reportID, transactionID: CONST.IOU.OPTIMISTIC_TRANSACTION_ID, isFromGlobalCreate: true, - merchant: 'Expense', + merchant: '(none)', }; const currentDate = '2025-04-01'; @@ -7861,7 +7861,6 @@ describe('actions/IOU', () => { .then(async () => { expect(await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`)).toStrictEqual({ ...transactionResult, - merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, iouRequestType: CONST.IOU.REQUEST_TYPE.SCAN, }); }); @@ -8021,7 +8020,7 @@ describe('actions/IOU', () => { }, }); }); - expect(updatedTransaction?.modifiedAmount).toBe(''); + expect(updatedTransaction?.modifiedAmount).toBe(0); }); }); diff --git a/tests/actions/ReportPreviewActionUtilsTest.ts b/tests/actions/ReportPreviewActionUtilsTest.ts index 2a99e36a3d04c..fbc95b430c051 100644 --- a/tests/actions/ReportPreviewActionUtilsTest.ts +++ b/tests/actions/ReportPreviewActionUtilsTest.ts @@ -95,9 +95,6 @@ describe('getReportPreviewAction', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); const transaction = { reportID: `${REPORT_ID}`, - amount: 100, - merchant: 'Test Merchant', - created: '2025-01-01', } as unknown as Transaction; // Simulate how components use a hook to pass the isReportArchived parameter @@ -140,9 +137,6 @@ describe('getReportPreviewAction', () => { const transaction = { reportID: `${REPORT_ID}`, - amount: 100, - merchant: 'Test Merchant', - created: '2025-01-01', } as unknown as Transaction; // Simulate how components use a hook to pass the isReportArchived parameter @@ -279,9 +273,6 @@ describe('getReportPreviewAction', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); const transaction = { reportID: `${REPORT_ID}`, - amount: 100, - merchant: 'Test Merchant', - created: '2025-01-01', } as unknown as Transaction; const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); @@ -394,9 +385,6 @@ describe('getReportPreviewAction', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); const transaction = { reportID: `${REPORT_ID}`, - amount: 100, - merchant: 'Test Merchant', - created: '2025-01-01', } as unknown as Transaction; const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); diff --git a/tests/unit/AddUnreportedExpenseSearchTest.ts b/tests/unit/AddUnreportedExpenseSearchTest.ts index 5eccc644c0ef9..6c7e90dce9703 100644 --- a/tests/unit/AddUnreportedExpenseSearchTest.ts +++ b/tests/unit/AddUnreportedExpenseSearchTest.ts @@ -107,7 +107,7 @@ describe('AddUnreportedExpense Search Functionality', () => { // Add merchant to searchable fields const merchant = getMerchant(transaction); - if (merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && merchant !== CONST.TRANSACTION.DEFAULT_MERCHANT) { + if (merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT) { searchableFields.push(merchant); } diff --git a/tests/unit/DebugUtilsTest.ts b/tests/unit/DebugUtilsTest.ts index 9f25b14510e88..20392806620ee 100644 --- a/tests/unit/DebugUtilsTest.ts +++ b/tests/unit/DebugUtilsTest.ts @@ -1233,9 +1233,8 @@ describe('DebugUtils', () => { accountID: 12345, }, [`${ONYXKEYS.COLLECTION.TRANSACTION}1` as const]: { - amount: 100, - created: '', - modifiedCreated: '', + amount: 0, + modifiedAmount: 0, }, }); const {reportAction} = @@ -1294,9 +1293,8 @@ describe('DebugUtils', () => { }; await Onyx.multiSet({ [`${ONYXKEYS.COLLECTION.TRANSACTION}1` as const]: { - amount: 100, - created: '', - modifiedCreated: '', + amount: 0, + modifiedAmount: 0, }, [`${ONYXKEYS.COLLECTION.REPORT}1` as const]: MOCK_CHAT_REPORT, [`${ONYXKEYS.COLLECTION.REPORT}2` as const]: MOCK_IOU_REPORT, @@ -1360,9 +1358,8 @@ describe('DebugUtils', () => { }; await Onyx.multiSet({ [`${ONYXKEYS.COLLECTION.TRANSACTION}1` as const]: { - amount: 100, - created: '', - modifiedCreated: '', + amount: 0, + modifiedAmount: 0, }, [`${ONYXKEYS.COLLECTION.REPORT}1` as const]: MOCK_CHAT_REPORT, [`${ONYXKEYS.COLLECTION.REPORT}2` as const]: MOCK_IOU_REPORT, diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 2ea0f4a436206..cf4446a6d3053 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -186,7 +186,7 @@ describe('ModifiedExpenseMessage', () => { }); }); - describe('when the amount is changed from zero', () => { + describe('when the amount is changed while the original value was partial', () => { const reportAction = { ...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, @@ -199,7 +199,7 @@ describe('ModifiedExpenseMessage', () => { }; it('returns the correct text message', () => { - const expectedResult = `changed the amount to $18.00 (previously $0.00)`; + const expectedResult = `set the amount to $18.00`; const result = getForReportAction({reportAction, policyID: report.policyID}); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index efbfca5b82b63..c6d5e98f20bbd 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -7836,8 +7836,7 @@ describe('ReportUtils', () => { const transaction: Transaction = { ...createRandomTransaction(Number(transactionID)), reportID: parentReport.reportID, - created: '', - modifiedCreated: '', + amount: 0, }; await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction); await waitForBatchedUpdates(); @@ -7862,8 +7861,7 @@ describe('ReportUtils', () => { const transaction: Transaction = { ...createRandomTransaction(12345), reportID: parentReport.reportID, - created: '', - modifiedCreated: '', + amount: 0, }; await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction); await waitForBatchedUpdates(); diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 22961bd59d360..5f3ad8039f36d 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -398,7 +398,7 @@ const searchResults: OnyxTypes.SearchResults = { currency: 'USD', hasEReceipt: false, merchant: 'Expense', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: 'Expense', @@ -427,7 +427,7 @@ const searchResults: OnyxTypes.SearchResults = { currency: 'USD', hasEReceipt: false, merchant: 'Expense', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: 'Expense', @@ -457,7 +457,7 @@ const searchResults: OnyxTypes.SearchResults = { currency: 'VND', hasEReceipt: false, merchant: '(none)', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -486,7 +486,7 @@ const searchResults: OnyxTypes.SearchResults = { currency: 'VND', hasEReceipt: false, merchant: '(none)', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -773,7 +773,7 @@ const transactionsListItems = [ currency: 'USD', date: '2024-12-21', formattedFrom: 'Admin', - formattedMerchant: '', + formattedMerchant: 'Expense', formattedTo: '', formattedTotal: 5000, from: { @@ -785,14 +785,14 @@ const transactionsListItems = [ hasEReceipt: false, keyForList: '1', merchant: 'Expense', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: 'Expense', parentTransactionID: '', pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, reportID: '123456789', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -832,7 +832,7 @@ const transactionsListItems = [ currency: 'USD', date: '2024-12-21', formattedFrom: 'Admin', - formattedMerchant: '', + formattedMerchant: 'Expense', formattedTo: 'Admin', formattedTotal: 5000, from: { @@ -844,13 +844,13 @@ const transactionsListItems = [ hasEReceipt: false, keyForList: '2', merchant: 'Expense', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: 'Expense', parentTransactionID: '', reportID: '11111', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -901,7 +901,7 @@ const transactionsListItems = [ currency: 'VND', hasEReceipt: false, merchant: '(none)', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -926,7 +926,7 @@ const transactionsListItems = [ formattedTotal: 1200, formattedMerchant: '', date: '2025-03-05', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -965,7 +965,7 @@ const transactionsListItems = [ currency: 'VND', hasEReceipt: false, merchant: '(none)', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -990,7 +990,7 @@ const transactionsListItems = [ formattedTotal: 3200, formattedMerchant: '', date: '2025-03-05', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -1067,7 +1067,7 @@ const transactionReportGroupListItems = [ date: '2024-12-21', exported: '', formattedFrom: 'Admin', - formattedMerchant: '', + formattedMerchant: 'Expense', formattedTo: '', formattedTotal: 5000, from: { @@ -1079,14 +1079,14 @@ const transactionReportGroupListItems = [ hasEReceipt: false, keyForList: '1', merchant: 'Expense', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: 'Expense', parentTransactionID: '', pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, reportID: '123456789', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -1172,7 +1172,7 @@ const transactionReportGroupListItems = [ currency: 'USD', date: '2024-12-21', formattedFrom: 'Admin', - formattedMerchant: '', + formattedMerchant: 'Expense', formattedTo: 'Admin', formattedTotal: 5000, from: { @@ -1190,13 +1190,13 @@ const transactionReportGroupListItems = [ ], keyForList: '2', merchant: 'Expense', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: 'Expense', parentTransactionID: '', reportID: '11111', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -1293,7 +1293,7 @@ const transactionReportGroupListItems = [ currency: 'VND', hasEReceipt: false, merchant: '(none)', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -1318,7 +1318,7 @@ const transactionReportGroupListItems = [ formattedTotal: 1200, formattedMerchant: '', date: '2025-03-05', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, @@ -1354,7 +1354,7 @@ const transactionReportGroupListItems = [ currency: 'VND', hasEReceipt: false, merchant: '(none)', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -1379,7 +1379,7 @@ const transactionReportGroupListItems = [ formattedTotal: 3200, formattedMerchant: '', date: '2025-03-05', - shouldShowMerchant: false, + shouldShowMerchant: true, shouldShowYear: true, shouldShowYearSubmitted: true, shouldShowYearApproved: false, diff --git a/tests/unit/Search/handleActionButtonPressTest.ts b/tests/unit/Search/handleActionButtonPressTest.ts index fa29076f3af66..8786fc8a41ef2 100644 --- a/tests/unit/Search/handleActionButtonPressTest.ts +++ b/tests/unit/Search/handleActionButtonPressTest.ts @@ -110,7 +110,7 @@ const mockReportItemWithHold = { hasEReceipt: false, managerID: 1206, merchant: 'Qatar', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', @@ -208,7 +208,7 @@ const mockReportItemWithHold = { currency: 'USD', hasEReceipt: false, merchant: 'Forbes', - modifiedAmount: '', + modifiedAmount: 0, modifiedCreated: '', modifiedCurrency: '', modifiedMerchant: '', diff --git a/tests/unit/TransactionPreviewUtils.test.ts b/tests/unit/TransactionPreviewUtils.test.ts index 0501c0816a9da..9daede4b6fa9d 100644 --- a/tests/unit/TransactionPreviewUtils.test.ts +++ b/tests/unit/TransactionPreviewUtils.test.ts @@ -106,15 +106,15 @@ describe('TransactionPreviewUtils', () => { expect(result.displayAmountText.text).toEqual('$0.00'); }); - it('returns missing field message when appropriate', () => { + it('returns merchant missing and amount missing message when appropriate', () => { const functionArgs = { ...basicProps, - transaction: {...basicProps.transaction, created: '', amount: 100}, + transaction: {...basicProps.transaction, merchant: '', amount: 0}, originalTransaction: undefined, shouldShowRBR: true, }; const result = getTransactionPreviewTextAndTranslationPaths(functionArgs); - expect(result.RBRMessage.translationPath).toEqual('iou.missingMerchant'); + expect(result.RBRMessage.translationPath).toEqual('violations.reviewRequired'); }); it('should display showCashOrCard in previewHeaderText', () => { @@ -140,12 +140,7 @@ describe('TransactionPreviewUtils', () => { }); it('displays description when receipt is being scanned', () => { - const functionArgs = { - ...basicProps, - transaction: {...basicProps.transaction, merchant: '(none)', receipt: {state: CONST.IOU.RECEIPT_STATE.SCANNING}}, - originalTransaction: undefined, - merchant: 'Expense', - }; + const functionArgs = {...basicProps, transaction: {...basicProps.transaction, receipt: {state: CONST.IOU.RECEIPT_STATE.SCANNING}}, originalTransaction: undefined}; const result = getTransactionPreviewTextAndTranslationPaths(functionArgs); expect(result.previewHeaderText).toEqual(expect.arrayContaining([{translationPath: 'common.receipt'}])); }); @@ -160,7 +155,7 @@ describe('TransactionPreviewUtils', () => { const functionArgs = { ...basicProps, transactionDetails: {amount: 300, currency: 'EUR'}, - transaction: {...basicProps.transaction, merchant: '(none)', receipt: {state: CONST.IOU.RECEIPT_STATE.SCANNING}}, + transaction: {...basicProps.transaction, receipt: {state: CONST.IOU.RECEIPT_STATE.SCANNING}}, originalTransaction: undefined, }; const result = getTransactionPreviewTextAndTranslationPaths(functionArgs); diff --git a/tests/unit/TransactionUtilsTest.ts b/tests/unit/TransactionUtilsTest.ts index 924d43dfda5dc..845fc55798e19 100644 --- a/tests/unit/TransactionUtilsTest.ts +++ b/tests/unit/TransactionUtilsTest.ts @@ -430,7 +430,6 @@ describe('TransactionUtils', () => { name: CONST.CUSTOM_UNITS.NAME_DISTANCE, }, }, - merchant: '(none)', }); expect(TransactionUtils.getTransactionType(transaction)).toBe(CONST.SEARCH.TRANSACTION_TYPE.DISTANCE); @@ -607,7 +606,7 @@ describe('TransactionUtils', () => { it('should return (none) if transaction has no merchant', () => { const transaction = generateTransaction(); const merchant = TransactionUtils.getMerchant(transaction); - expect(merchant).toBe('Expense'); + expect(merchant).toBe('(none)'); }); it('should return modified merchant if transaction has modified merchant', () => { diff --git a/tests/utils/collections/transaction.ts b/tests/utils/collections/transaction.ts index fb199363b2c0d..cffd6cb6a63d4 100644 --- a/tests/utils/collections/transaction.ts +++ b/tests/utils/collections/transaction.ts @@ -41,7 +41,7 @@ export default function createRandomTransaction(index: number): Transaction { receipt: {filename: randWord()}, reimbursable: randBoolean(), hasEReceipt: randBoolean(), - modifiedAmount: '', + modifiedAmount: 0, }; }