@@ -392,6 +392,8 @@ function getUpdatedTransaction({
392392 shouldUpdateReceiptState ?: boolean ;
393393 policy ?: OnyxEntry < Policy > ;
394394} ) : Transaction {
395+ const isUnReportedExpense = transaction ?. reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
396+
395397 // Only changing the first level fields so no need for deep clone now
396398 const updatedTransaction = lodashDeepClone ( transaction ) ;
397399 let shouldStopSmartscan = false ;
@@ -408,8 +410,7 @@ function getUpdatedTransaction({
408410 shouldStopSmartscan = true ;
409411 }
410412 if ( Object . hasOwn ( transactionChanges , 'amount' ) && typeof transactionChanges . amount === 'number' ) {
411- updatedTransaction . modifiedAmount = isFromExpenseReport ? - transactionChanges . amount : transactionChanges . amount ;
412- shouldStopSmartscan = true ;
413+ updatedTransaction . modifiedAmount = isFromExpenseReport || isUnReportedExpense ? - transactionChanges . amount : transactionChanges . amount ;
413414 }
414415 if ( Object . hasOwn ( transactionChanges , 'currency' ) ) {
415416 updatedTransaction . modifiedCurrency = transactionChanges . currency ;
@@ -437,7 +438,7 @@ function getUpdatedTransaction({
437438
438439 const distanceInMeters = getDistanceInMeters ( transaction , unit ) ;
439440 const amount = DistanceRequestUtils . getDistanceRequestAmount ( distanceInMeters , unit , rate ?? 0 ) ;
440- const updatedAmount = isFromExpenseReport ? - amount : amount ;
441+ const updatedAmount = isFromExpenseReport || isUnReportedExpense ? - amount : amount ;
441442 const updatedMerchant = DistanceRequestUtils . getDistanceMerchant ( true , distanceInMeters , unit , rate , transaction . currency , translateLocal , ( digit ) =>
442443 toLocaleDigit ( IntlStore . getCurrentLocale ( ) , digit ) ,
443444 ) ;
@@ -476,7 +477,7 @@ function getUpdatedTransaction({
476477
477478 const distanceInMeters = getDistanceInMeters ( transaction , oldMileageRate ?. unit ) ;
478479 const amount = DistanceRequestUtils . getDistanceRequestAmount ( distanceInMeters , unit , rate ?? 0 ) ;
479- const updatedAmount = isFromExpenseReport ? - amount : amount ;
480+ const updatedAmount = isFromExpenseReport || isUnReportedExpense ? - amount : amount ;
480481 const updatedCurrency = updatedMileageRate . currency ?? CONST . CURRENCY . USD ;
481482 const updatedMerchant = DistanceRequestUtils . getDistanceMerchant ( true , distanceInMeters , unit , rate , updatedCurrency , translateLocal , ( digit ) =>
482483 toLocaleDigit ( IntlStore . getCurrentLocale ( ) , digit ) ,
@@ -562,7 +563,7 @@ function getDescription(transaction: OnyxInputOrEntry<Transaction>): string {
562563 */
563564function getAmount ( transaction : OnyxInputOrEntry < Transaction > , isFromExpenseReport = false , isFromTrackedExpense = false ) : number {
564565 // IOU requests cannot have negative values, but they can be stored as negative values, let's return absolute value
565- if ( ! isFromExpenseReport || isFromTrackedExpense ) {
566+ if ( ! isFromExpenseReport && ! isFromTrackedExpense ) {
566567 const amount = transaction ?. modifiedAmount ?? 0 ;
567568 if ( amount ) {
568569 return Math . abs ( amount ) ;
@@ -666,9 +667,9 @@ function isUnreportedAndHasInvalidDistanceRateTransaction(transaction: OnyxInput
666667 // eslint-disable-next-line deprecation/deprecation
667668 const policy = policyParam ?? getPolicy ( report ?. policyID ) ;
668669 const { rate} = DistanceRequestUtils . getRate ( { transaction, policy} ) ;
669- const isUnreported = ! transaction . reportID || transaction . reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
670+ const isUnreportedExpense = ! transaction . reportID || transaction . reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
670671
671- if ( isUnreported && ! rate ) {
672+ if ( isUnreportedExpense && ! rate ) {
672673 return true ;
673674 }
674675 }
0 commit comments