@@ -448,6 +448,30 @@ function areRequiredFieldsEmpty(transaction: OnyxEntry<Transaction>, reportTrans
448448 return ( isMerchantRequired && isMerchantMissing ( transaction ) ) || isAmountMissing ( transaction ) || isCreatedMissing ( transaction ) ;
449449}
450450
451+ function getClearedPendingFields ( transactionChanges : TransactionChanges ) {
452+ return {
453+ ...Object . fromEntries ( Object . keys ( transactionChanges ) . map ( ( key ) => [ key , null ] ) ) ,
454+ ...( Object . hasOwn ( transactionChanges , 'comment' ) && { comment : null } ) ,
455+ ...( Object . hasOwn ( transactionChanges , 'created' ) && { created : null } ) ,
456+ ...( Object . hasOwn ( transactionChanges , 'amount' ) && { amount : null } ) ,
457+ ...( Object . hasOwn ( transactionChanges , 'currency' ) && { currency : null } ) ,
458+ ...( Object . hasOwn ( transactionChanges , 'merchant' ) && { merchant : null } ) ,
459+ ...( Object . hasOwn ( transactionChanges , 'waypoints' ) && { waypoints : null } ) ,
460+ ...( Object . hasOwn ( transactionChanges , 'reimbursable' ) && { reimbursable : null } ) ,
461+ ...( Object . hasOwn ( transactionChanges , 'billable' ) && { billable : null } ) ,
462+ ...( Object . hasOwn ( transactionChanges , 'category' ) && { category : null } ) ,
463+ ...( Object . hasOwn ( transactionChanges , 'tag' ) && { tag : null } ) ,
464+ ...( Object . hasOwn ( transactionChanges , 'taxAmount' ) && { taxAmount : null } ) ,
465+ ...( Object . hasOwn ( transactionChanges , 'taxCode' ) && { taxCode : null } ) ,
466+ ...( Object . hasOwn ( transactionChanges , 'attendees' ) && { attendees : null } ) ,
467+ ...( Object . hasOwn ( transactionChanges , 'distance' ) && {
468+ quantity : null ,
469+ amount : null ,
470+ merchant : null ,
471+ } ) ,
472+ } ;
473+ }
474+
451475/**
452476 * Given the edit made to the expense, return an updated transaction object.
453477 */
@@ -1972,6 +1996,7 @@ export {
19721996 getTaxName ,
19731997 getEnabledTaxRateCount ,
19741998 getUpdatedTransaction ,
1999+ getClearedPendingFields ,
19752000 getDescription ,
19762001 getRequestType ,
19772002 getExpenseType ,
0 commit comments