diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index bbe58c33401a..86db1d3ddd1f 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -24,10 +24,11 @@ import { buildTransactionThread, findSelfDMReportID, getReportTransactions, + getTransactionDetails, hasViolations as hasViolationsReportUtils, shouldEnableNegative, } from '@libs/ReportUtils'; -import {getAmount, isOnHold, waypointHasValidAddress} from '@libs/TransactionUtils'; +import {isOnHold, waypointHasValidAddress} from '@libs/TransactionUtils'; import ViolationsUtils from '@libs/Violations/ViolationsUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -886,10 +887,11 @@ function changeTransactionsReport( // 3. Keep track of the new report totals const isUnreported = reportID === CONST.REPORT.UNREPORTED_REPORT_ID; const targetReportID = isUnreported ? selfDMReportID : reportID; - const transactionAmount = getAmount(transaction, undefined, undefined, allowNegative); + const transactionAmount = getTransactionDetails(transaction, undefined, undefined, allowNegative)?.amount ?? 0; + const updatedReportTotal = transactionAmount < 0 ? (oldReport?.total ?? 0 - transactionAmount) : (oldReport?.total ?? 0 + transactionAmount); if (oldReport) { - updatedReportTotals[oldReportID] = (updatedReportTotals[oldReportID] ? updatedReportTotals[oldReportID] : (oldReport?.total ?? 0)) + transactionAmount; + updatedReportTotals[oldReportID] = updatedReportTotals[oldReportID] ? updatedReportTotals[oldReportID] : updatedReportTotal; updatedReportNonReimbursableTotals[oldReportID] = (updatedReportNonReimbursableTotals[oldReportID] ? updatedReportNonReimbursableTotals[oldReportID] : (oldReport?.nonReimbursableTotal ?? 0)) + (transaction?.reimbursable ? 0 : transactionAmount); diff --git a/src/pages/iou/SplitExpensePage.tsx b/src/pages/iou/SplitExpensePage.tsx index e2725decc8c4..932418b17df9 100644 --- a/src/pages/iou/SplitExpensePage.tsx +++ b/src/pages/iou/SplitExpensePage.tsx @@ -185,7 +185,10 @@ function SplitExpensePage({route}: SplitExpensePageProps) { splitExpenses, childTransactions.length, isBetaEnabled, - draftTransaction, + draftTransaction?.errors, + draftTransaction?.reportID, + draftTransaction?.comment?.originalTransactionID, + draftTransaction?.comment?.splitExpensesTotal, sumOfSplitExpenses, transactionDetailsAmount, isPerDiem, @@ -193,19 +196,19 @@ function SplitExpensePage({route}: SplitExpensePageProps) { splitFieldDataFromChildTransactions, allTransactions, allReports, + allReportNameValuePairs, currentSearchHash, policyCategories, expenseReportPolicy, policyRecentlyUsedCategories, + iouReport, + chatReport, + iouActions, + isChatIOUReportArchived, splitFieldDataFromOriginalTransaction, translate, transactionID, transactionDetails?.currency, - isChatIOUReportArchived, - iouReport, - iouActions, - chatReport, - allReportNameValuePairs, ]); const onSplitExpenseAmountChange = useCallback( @@ -355,6 +358,7 @@ function SplitExpensePage({route}: SplitExpensePageProps) { })} onBackButtonPress={() => Navigation.goBack(backTo)} /> + (