From 68fcb188e14dbfccb53869fd90f0261c089f5f43 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Tue, 14 Oct 2025 09:28:14 +0200 Subject: [PATCH] Enhance AddUnreportedExpense component to disallow negative expense values --- src/pages/AddUnreportedExpense.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/AddUnreportedExpense.tsx b/src/pages/AddUnreportedExpense.tsx index c1c18f55be9..1b06c5f007d 100644 --- a/src/pages/AddUnreportedExpense.tsx +++ b/src/pages/AddUnreportedExpense.tsx @@ -24,7 +24,7 @@ import interceptAnonymousUser from '@libs/interceptAnonymousUser'; import type {AddUnreportedExpensesParamList} from '@libs/Navigation/types'; import Permissions from '@libs/Permissions'; import {canSubmitPerDiemExpenseFromWorkspace, getPerDiemCustomUnit} from '@libs/PolicyUtils'; -import {isIOUReport} from '@libs/ReportUtils'; +import {getTransactionDetails, isIOUReport} from '@libs/ReportUtils'; import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; import tokenizedSearch from '@libs/tokenizedSearch'; import {createUnreportedExpenseSections, getAmount, getCurrency, getDescription, getMerchant, isPerDiemRequest} from '@libs/TransactionUtils'; @@ -74,6 +74,11 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) { return false; } + // Negative values are not allowed for unreported expenses + if ((getTransactionDetails(item)?.amount ?? 0) < 0) { + return false; + } + if (isPerDiemRequest(item)) { // Only show per diem expenses if the target workspace has per diem enabled and the per diem expense was created in the same workspace const workspacePerDiemUnit = getPerDiemCustomUnit(policy);