@@ -75,7 +75,6 @@ import type {OnyxData} from '@src/types/onyx/Request';
7575import type {
7676 Comment ,
7777 Receipt ,
78- Routes ,
7978 TransactionChanges ,
8079 TransactionCustomUnit ,
8180 TransactionPendingFieldsKey ,
@@ -114,17 +113,13 @@ type TransactionParams = {
114113 splitsStartDate ?: string ;
115114 splitsEndDate ?: string ;
116115 distance ?: number ;
117- customUnitRateID ?: string ;
118- waypoints ?: WaypointCollection ;
119116 odometerStart ?: number ;
120117 odometerEnd ?: number ;
121- routes ?: Routes ;
122118 gpsCoordinates ?: string ;
123119 type ?: ValueOf < typeof CONST . TRANSACTION . TYPE > ;
124120 count ?: number ;
125121 rate ?: number ;
126122 unit ?: ValueOf < typeof CONST . TIME_TRACKING . UNIT > ;
127- commentType ?: ValueOf < typeof CONST . TRANSACTION . TYPE > ;
128123} ;
129124
130125type BuildOptimisticTransactionParams = {
@@ -474,16 +469,12 @@ function buildOptimisticTransaction(params: BuildOptimisticTransactionParams): T
474469 splitExpensesTotal,
475470 participants,
476471 pendingAction = CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD ,
477- customUnitRateID,
478- waypoints,
479472 odometerStart,
480473 odometerEnd,
481- routes,
482474 type,
483475 count,
484476 rate,
485477 unit,
486- commentType,
487478 } = transactionParams ;
488479 // transactionIDs are random, positive, 64-bit numeric strings.
489480 // Because JS can only handle 53-bit numbers, transactionIDs are strings in the front-end (just like reportActionID)
@@ -517,28 +508,14 @@ function buildOptimisticTransaction(params: BuildOptimisticTransactionParams): T
517508 if ( splitExpensesTotal ) {
518509 commentJSON . splitExpensesTotal = splitExpensesTotal ;
519510 }
520- if ( waypoints ) {
521- commentJSON . waypoints = waypoints ;
522- }
523- if ( commentType ) {
524- commentJSON . type = commentType ;
525- }
526511
527- const isMapDistanceTransaction = ! ! pendingFields ?. waypoints || existingTransaction ?. comment ?. waypoints ?. waypoint0 ;
512+ const isMapDistanceTransaction = ! ! pendingFields ?. waypoints ;
528513 const isManualDistanceTransaction = isManualDistanceRequest ( existingTransaction ) ;
529514 const isOdometerDistanceTransaction = isOdometerDistanceRequest ( existingTransaction ) ;
530515 if ( isMapDistanceTransaction || isManualDistanceTransaction || isOdometerDistanceTransaction ) {
531- // If customUnit is provided (e.g., for split expenses), use it directly
532- // Otherwise, build customUnit from distance parameter
533- if ( customUnit ) {
534- lodashSet ( commentJSON , 'customUnit' , customUnit ) ;
535- } else {
536- // Set the distance unit, which comes from the policy distance unit or the P2P rate data
537- lodashSet ( commentJSON , 'customUnit.distanceUnit' , DistanceRequestUtils . getUpdatedDistanceUnit ( { transaction : existingTransaction , policy} ) ) ;
538- lodashSet ( commentJSON , 'customUnit.quantity' , distance ) ;
539- lodashSet ( commentJSON , 'customUnit.customUnitRateID' , customUnitRateID ) ;
540- lodashSet ( commentJSON , 'customUnit.name' , existingTransaction ?. comment ?. customUnit ?. name ?? CONST . CUSTOM_UNITS . NAME_DISTANCE ) ;
541- }
516+ // Set the distance unit, which comes from the policy distance unit or the P2P rate data
517+ lodashSet ( commentJSON , 'customUnit.distanceUnit' , DistanceRequestUtils . getUpdatedDistanceUnit ( { transaction : existingTransaction , policy} ) ) ;
518+ lodashSet ( commentJSON , 'customUnit.quantity' , distance ) ;
542519 }
543520
544521 const isPerDiemTransaction = ! ! pendingFields ?. subRates ;
@@ -583,9 +560,6 @@ function buildOptimisticTransaction(params: BuildOptimisticTransactionParams): T
583560 cardID : existingTransaction ?. cardID ,
584561 cardName : existingTransaction ?. cardName ,
585562 cardNumber : existingTransaction ?. cardNumber ,
586- // Use conditional spread to avoid creating the key if it's undefined, which would break lodashHas checks.
587- ...( existingTransaction ?. iouRequestType ? { iouRequestType : existingTransaction . iouRequestType } : { } ) ,
588- routes,
589563 } ;
590564}
591565
@@ -692,14 +666,12 @@ function getUpdatedTransaction({
692666 isFromExpenseReport,
693667 shouldUpdateReceiptState = true ,
694668 policy = undefined ,
695- isDraftSplitTransaction = false ,
696669} : {
697670 transaction : Transaction ;
698671 transactionChanges : TransactionChanges ;
699672 isFromExpenseReport : boolean ;
700673 shouldUpdateReceiptState ?: boolean ;
701674 policy ?: OnyxEntry < Policy > ;
702- isDraftSplitTransaction ?: boolean ;
703675} ) : Transaction {
704676 const isUnReportedExpense = transaction ?. reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
705677
@@ -734,10 +706,7 @@ function getUpdatedTransaction({
734706
735707 if ( Object . hasOwn ( transactionChanges , 'waypoints' ) ) {
736708 updatedTransaction . modifiedWaypoints = transactionChanges . waypoints ;
737- // For draft split transactions, we don't want to set isLoading to true as all the split transactions are in draft state
738- if ( ! isDraftSplitTransaction ) {
739- updatedTransaction . isLoading = true ;
740- }
709+ updatedTransaction . isLoading = true ;
741710 shouldStopSmartscan = true ;
742711
743712 if ( ! transactionChanges . routes ?. route0 ?. geometry ?. coordinates ) {
@@ -772,10 +741,6 @@ function getUpdatedTransaction({
772741 }
773742 }
774743
775- if ( Object . hasOwn ( transactionChanges , 'routes' ) ) {
776- updatedTransaction . routes = transactionChanges . routes ;
777- }
778-
779744 if ( Object . hasOwn ( transactionChanges , 'customUnitRateID' ) ) {
780745 lodashSet ( updatedTransaction , 'comment.customUnit.customUnitRateID' , transactionChanges . customUnitRateID ) ;
781746 lodashSet ( updatedTransaction , 'comment.customUnit.defaultP2PRate' , null ) ;
0 commit comments