From 25e4a22eabb8258ef22993db942d2c1a5d3a0a2e Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Mon, 13 Oct 2025 13:24:48 +0200 Subject: [PATCH] fix building optimistic transaction for negative values --- src/libs/actions/IOU.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8a3b0675f3e8..a1d2e636a8d1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -197,6 +197,7 @@ import { isTrackExpenseReport, prepareOnboardingOnyxData, shouldCreateNewMoneyRequestReport as shouldCreateNewMoneyRequestReportReportUtils, + shouldEnableNegative, updateReportPreview, } from '@libs/ReportUtils'; import {getCurrentSearchQueryJSON} from '@libs/SearchQueryUtils'; @@ -4309,6 +4310,7 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U updatedTransaction, allowNegative, ); + if (!hasPendingWaypoints && !(hasModifiedDistanceRate && isFetchingWaypointsFromServer(transaction))) { apiParams.reportActionID = updatedReportAction.reportActionID; @@ -4753,7 +4755,8 @@ function getUpdateTrackExpenseParams( // - we're updating the distance rate while the waypoints are still pending // In these cases, there isn't a valid optimistic mileage data we can use, // and the report action is created on the server with the distance-related response from the MapBox API - const updatedReportAction = buildOptimisticModifiedExpenseReportAction(transactionThread, transaction, transactionChanges, false, policy, updatedTransaction); + const allowNegative = shouldEnableNegative(transactionThread ?? undefined); + const updatedReportAction = buildOptimisticModifiedExpenseReportAction(transactionThread, transaction, transactionChanges, false, policy, updatedTransaction, allowNegative); if (!hasPendingWaypoints && !(hasModifiedDistanceRate && isFetchingWaypointsFromServer(transaction))) { apiParams.reportActionID = updatedReportAction.reportActionID;