@@ -2424,7 +2424,7 @@ describe('actions/Report', () => {
24242424 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
24252425
24262426 // When moving to another workspace
2427- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , true , false , false ) ;
2427+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , true , false , false ) ;
24282428 await waitForBatchedUpdates ( ) ;
24292429
24302430 // Then the expense report should not be archived anymore
@@ -2462,12 +2462,16 @@ describe('actions/Report', () => {
24622462 chatReportID : '2' ,
24632463 parentReportID : '2' ,
24642464 } ;
2465+ const parentReport : OnyxTypes . Report = {
2466+ ...createRandomReport ( 2 , CONST . REPORT . CHAT_TYPE . POLICY_EXPENSE_CHAT ) ,
2467+ policyID : '1' ,
2468+ } ;
24652469
24662470 const newPolicy = createRandomPolicy ( 2 ) ;
24672471 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
24682472
24692473 // When moving to another workspace
2470- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2474+ Report . changeReportPolicy ( expenseReport , parentReport , newPolicy , 1 , '' , false , false , false ) ;
24712475 await waitForBatchedUpdates ( ) ;
24722476
24732477 // Then the expense report chatReportID and parentReportID should be updated to the new expense chat reportID
@@ -2524,7 +2528,7 @@ describe('actions/Report', () => {
25242528 } ;
25252529 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
25262530
2527- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2531+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , false , false , false ) ;
25282532 await waitForBatchedUpdates ( ) ;
25292533
25302534 const updatedReport = await new Promise < OnyxEntry < OnyxTypes . Report > > ( ( resolve ) => {
@@ -2607,7 +2611,7 @@ describe('actions/Report', () => {
26072611 } ;
26082612 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
26092613
2610- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2614+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , false , false , false ) ;
26112615 await waitForBatchedUpdates ( ) ;
26122616
26132617 // Then the report total should correctly include expense (-1000) and refund (+500) = -500
@@ -2678,7 +2682,7 @@ describe('actions/Report', () => {
26782682 } ;
26792683 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
26802684
2681- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2685+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , false , false , false ) ;
26822686 await waitForBatchedUpdates ( ) ;
26832687
26842688 // Then only AUD transaction should contribute to total (-1000), USD is excluded
@@ -2717,20 +2721,21 @@ describe('actions/Report', () => {
27172721 } ) ;
27182722
27192723 // When moving to another workspace
2720- Report . changeReportPolicyAndInviteSubmitter (
2721- expenseReport ,
2722- createRandomPolicy ( Number ( 2 ) ) ,
2723- 1 ,
2724- '' ,
2725- true ,
2726- false ,
2727- false ,
2728- {
2724+ Report . changeReportPolicyAndInviteSubmitter ( {
2725+ report : expenseReport ,
2726+ parentReport : undefined ,
2727+ policy : createRandomPolicy ( Number ( 2 ) ) ,
2728+ currentUserAccountID : 1 ,
2729+ email : '' ,
2730+ hasViolationsParam : true ,
2731+ isChangePolicyTrainingModalDismissed : false ,
2732+ isASAPSubmitBetaEnabled : false ,
2733+ employeeList : {
27292734 [ adminEmail ] : { role : CONST . POLICY . ROLE . ADMIN } ,
27302735 } ,
2731- TestHelper . formatPhoneNumber ,
2732- undefined ,
2733- ) ;
2736+ formatPhoneNumber : TestHelper . formatPhoneNumber ,
2737+ isReportLastVisibleArchived : undefined ,
2738+ } ) ;
27342739 await waitForBatchedUpdates ( ) ;
27352740
27362741 // Then the expense report should not be archived anymore
@@ -2804,7 +2809,19 @@ describe('actions/Report', () => {
28042809 await waitForBatchedUpdates ( ) ;
28052810
28062811 // Call changeReportPolicyAndInviteSubmitter
2807- Report . changeReportPolicyAndInviteSubmitter ( expenseReport , newPolicy , 1 , '' , true , false , false , employeeList , TestHelper . formatPhoneNumber , false ) ;
2812+ Report . changeReportPolicyAndInviteSubmitter ( {
2813+ report : expenseReport ,
2814+ parentReport : undefined ,
2815+ policy : newPolicy ,
2816+ currentUserAccountID : 1 ,
2817+ email : '' ,
2818+ hasViolationsParam : true ,
2819+ isChangePolicyTrainingModalDismissed : false ,
2820+ isASAPSubmitBetaEnabled : false ,
2821+ employeeList,
2822+ formatPhoneNumber : TestHelper . formatPhoneNumber ,
2823+ isReportLastVisibleArchived : false ,
2824+ } ) ;
28082825 await waitForBatchedUpdates ( ) ;
28092826
28102827 // Simulate network failure
@@ -2991,7 +3008,7 @@ describe('actions/Report', () => {
29913008 type : CONST . REPORT . TYPE . EXPENSE ,
29923009 } ;
29933010 const policy = createRandomPolicy ( Number ( 1 ) ) ;
2994- Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3011+ Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
29953012 // eslint-disable-next-line @typescript-eslint/no-deprecated
29963013 expect ( buildNextStepNew ) . toHaveBeenCalledWith ( {
29973014 report,
@@ -3032,7 +3049,7 @@ describe('actions/Report', () => {
30323049 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , transaction ) ;
30333050 await waitForBatchedUpdates ( ) ;
30343051
3035- const { optimisticData, successData, failureData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3052+ const { optimisticData, successData, failureData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
30363053
30373054 // Find the transaction optimistic data
30383055 const transactionOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
@@ -3080,7 +3097,7 @@ describe('actions/Report', () => {
30803097 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , transaction ) ;
30813098 await waitForBatchedUpdates ( ) ;
30823099
3083- const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3100+ const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
30843101
30853102 // Should NOT find transaction optimistic data when currencies are the same
30863103 const transactionOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
@@ -3115,7 +3132,7 @@ describe('actions/Report', () => {
31153132 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , transaction ) ;
31163133 await waitForBatchedUpdates ( ) ;
31173134
3118- const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3135+ const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
31193136
31203137 // Should NOT find transaction optimistic data when transaction matches destination currency
31213138 const transactionOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
@@ -3163,7 +3180,7 @@ describe('actions/Report', () => {
31633180 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ nonMatchingTransactionID } ` , nonMatchingTransaction ) ;
31643181 await waitForBatchedUpdates ( ) ;
31653182
3166- const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3183+ const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
31673184
31683185 // Should NOT find optimistic data for the matching transaction (USD matches USD destination)
31693186 const matchingOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ matchingTransactionID } ` ) ;
0 commit comments