@@ -5,7 +5,9 @@ import type {OnyxEntry} from 'react-native-onyx';
55import {
66 updateMoneyRequestAmountAndCurrency ,
77 updateMoneyRequestAttendees ,
8+ updateMoneyRequestBillable ,
89 updateMoneyRequestCategory ,
10+ updateMoneyRequestDate ,
911 updateMoneyRequestDistance ,
1012 updateMoneyRequestTag ,
1113} from '@libs/actions/IOU/UpdateMoneyRequest' ;
@@ -728,6 +730,159 @@ describe('actions/IOU/UpdateMoneyRequest', () => {
728730 } ) ;
729731 } ) ;
730732
733+ describe ( 'updateMoneyRequestDate' , ( ) => {
734+ it ( 'should update the transaction created date' , async ( ) => {
735+ // Given an expense transaction with an expense report
736+ const transactionID = 'txnDate1' ;
737+ const transactionThreadReportID = 'threadDate1' ;
738+ const parentReportID = 'parentDate1' ;
739+ const policyID = '10' ;
740+ const originalDate = '2026-01-01' ;
741+ const newDate = '2026-01-15' ;
742+
743+ const parentReport : Report = {
744+ ...createRandomReport ( 1 , undefined ) ,
745+ reportID : parentReportID ,
746+ type : CONST . REPORT . TYPE . EXPENSE ,
747+ policyID,
748+ ownerAccountID : RORY_ACCOUNT_ID ,
749+ } ;
750+ const transactionThreadReport : Report = {
751+ ...createRandomReport ( 2 , undefined ) ,
752+ reportID : transactionThreadReportID ,
753+ parentReportID,
754+ type : CONST . REPORT . TYPE . CHAT ,
755+ } ;
756+ const fakeTransaction : Transaction = {
757+ ...createRandomTransaction ( 3 ) ,
758+ transactionID,
759+ reportID : parentReportID ,
760+ created : originalDate ,
761+ } ;
762+ const fakePolicy : Policy = createRandomPolicy ( Number ( policyID ) ) ;
763+
764+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ parentReportID } ` , parentReport ) ;
765+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID } ` , transactionThreadReport ) ;
766+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , fakeTransaction ) ;
767+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` , fakePolicy ) ;
768+
769+ // When updating the date
770+ updateMoneyRequestDate ( {
771+ transactionID,
772+ transactionThreadReport,
773+ parentReport,
774+ transactions : { [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ] : fakeTransaction } ,
775+ transactionViolations : { } ,
776+ value : newDate ,
777+ policy : fakePolicy ,
778+ policyTags : { } ,
779+ policyCategories : { } ,
780+ currentUserAccountIDParam : RORY_ACCOUNT_ID ,
781+ currentUserEmailParam : RORY_EMAIL ,
782+ isASAPSubmitBetaEnabled : false ,
783+ parentReportNextStep : undefined ,
784+ isOffline : false ,
785+ } ) ;
786+
787+ await waitForBatchedUpdates ( ) ;
788+
789+ // Then the modified date on the transaction should be updated
790+ const transactionAfter = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
791+ expect ( transactionAfter ?. modifiedCreated ) . toBe ( newDate ) ;
792+ } ) ;
793+ } ) ;
794+
795+ describe ( 'updateMoneyRequestBillable' , ( ) => {
796+ it ( 'should update the transaction billable field' , async ( ) => {
797+ // Given an expense transaction with billable = false
798+ const transactionID = 'txnBillable1' ;
799+ const transactionThreadReportID = 'threadBillable1' ;
800+ const parentReportID = 'parentBillable1' ;
801+ const policyID = '20' ;
802+
803+ const parentReport : Report = {
804+ ...createRandomReport ( 1 , undefined ) ,
805+ reportID : parentReportID ,
806+ type : CONST . REPORT . TYPE . EXPENSE ,
807+ policyID,
808+ ownerAccountID : RORY_ACCOUNT_ID ,
809+ } ;
810+ const transactionThreadReport : Report = {
811+ ...createRandomReport ( 2 , undefined ) ,
812+ reportID : transactionThreadReportID ,
813+ parentReportID,
814+ type : CONST . REPORT . TYPE . CHAT ,
815+ } ;
816+ const fakeTransaction : Transaction = {
817+ ...createRandomTransaction ( 3 ) ,
818+ transactionID,
819+ reportID : parentReportID ,
820+ billable : false ,
821+ } ;
822+ const fakePolicy : Policy = createRandomPolicy ( Number ( policyID ) ) ;
823+
824+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ parentReportID } ` , parentReport ) ;
825+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID } ` , transactionThreadReport ) ;
826+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , fakeTransaction ) ;
827+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` , fakePolicy ) ;
828+
829+ // When updating billable to true
830+ updateMoneyRequestBillable ( {
831+ transactionID,
832+ transactionThreadReport,
833+ parentReport,
834+ value : true ,
835+ policy : fakePolicy ,
836+ policyTagList : { } ,
837+ policyCategories : { } ,
838+ currentUserAccountIDParam : RORY_ACCOUNT_ID ,
839+ currentUserEmailParam : RORY_EMAIL ,
840+ isASAPSubmitBetaEnabled : false ,
841+ parentReportNextStep : undefined ,
842+ isOffline : false ,
843+ } ) ;
844+
845+ await waitForBatchedUpdates ( ) ;
846+
847+ // Then the transaction billable field should be updated
848+ const transactionAfter = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
849+ expect ( transactionAfter ?. billable ) . toBe ( true ) ;
850+ } ) ;
851+
852+ it ( 'should not update anything if transactionID is missing' , async ( ) => {
853+ // Given a transaction
854+ const transactionID = 'txnBillableNoOp' ;
855+ const fakeTransaction : Transaction = {
856+ ...createRandomTransaction ( 1 ) ,
857+ transactionID,
858+ billable : false ,
859+ } ;
860+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , fakeTransaction ) ;
861+
862+ // When updateMoneyRequestBillable is called with an undefined transactionID
863+ updateMoneyRequestBillable ( {
864+ transactionID : undefined ,
865+ transactionThreadReport : { reportID : '1' } ,
866+ parentReport : undefined ,
867+ value : true ,
868+ policy : undefined ,
869+ policyTagList : { } ,
870+ policyCategories : { } ,
871+ currentUserAccountIDParam : RORY_ACCOUNT_ID ,
872+ currentUserEmailParam : RORY_EMAIL ,
873+ isASAPSubmitBetaEnabled : false ,
874+ parentReportNextStep : undefined ,
875+ isOffline : false ,
876+ } ) ;
877+
878+ await waitForBatchedUpdates ( ) ;
879+
880+ // Then the original transaction billable value should be unchanged
881+ const transactionAfter = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
882+ expect ( transactionAfter ?. billable ) . toBe ( false ) ;
883+ } ) ;
884+ } ) ;
885+
731886 describe ( 'updateMoneyRequestDistance' , ( ) => {
732887 it ( 'should update transaction with distance and waypoints' , async ( ) => {
733888 // Given a distance request transaction with valid waypoints and existing data
0 commit comments