@@ -2484,7 +2484,7 @@ describe('actions/Report', () => {
24842484 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
24852485
24862486 // When moving to another workspace
2487- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , true , false , false ) ;
2487+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , true , false , false ) ;
24882488 await waitForBatchedUpdates ( ) ;
24892489
24902490 // Then the expense report should not be archived anymore
@@ -2522,12 +2522,16 @@ describe('actions/Report', () => {
25222522 chatReportID : '2' ,
25232523 parentReportID : '2' ,
25242524 } ;
2525+ const parentReport : OnyxTypes . Report = {
2526+ ...createRandomReport ( 2 , CONST . REPORT . CHAT_TYPE . POLICY_EXPENSE_CHAT ) ,
2527+ policyID : '1' ,
2528+ } ;
25252529
25262530 const newPolicy = createRandomPolicy ( 2 ) ;
25272531 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
25282532
25292533 // When moving to another workspace
2530- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2534+ Report . changeReportPolicy ( expenseReport , parentReport , newPolicy , 1 , '' , false , false , false ) ;
25312535 await waitForBatchedUpdates ( ) ;
25322536
25332537 // Then the expense report chatReportID and parentReportID should be updated to the new expense chat reportID
@@ -2584,7 +2588,7 @@ describe('actions/Report', () => {
25842588 } ;
25852589 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
25862590
2587- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2591+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , false , false , false ) ;
25882592 await waitForBatchedUpdates ( ) ;
25892593
25902594 const updatedReport = await new Promise < OnyxEntry < OnyxTypes . Report > > ( ( resolve ) => {
@@ -2667,7 +2671,7 @@ describe('actions/Report', () => {
26672671 } ;
26682672 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
26692673
2670- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2674+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , false , false , false ) ;
26712675 await waitForBatchedUpdates ( ) ;
26722676
26732677 // Then the report total should correctly include expense (-1000) and refund (+500) = -500
@@ -2738,7 +2742,7 @@ describe('actions/Report', () => {
27382742 } ;
27392743 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ newPolicy . id } ` , newPolicy ) ;
27402744
2741- Report . changeReportPolicy ( expenseReport , newPolicy , 1 , '' , false , false , false ) ;
2745+ Report . changeReportPolicy ( expenseReport , undefined , newPolicy , 1 , '' , false , false , false ) ;
27422746 await waitForBatchedUpdates ( ) ;
27432747
27442748 // Then only AUD transaction should contribute to total (-1000), USD is excluded
@@ -2777,20 +2781,21 @@ describe('actions/Report', () => {
27772781 } ) ;
27782782
27792783 // When moving to another workspace
2780- Report . changeReportPolicyAndInviteSubmitter (
2781- expenseReport ,
2782- createRandomPolicy ( Number ( 2 ) ) ,
2783- 1 ,
2784- '' ,
2785- true ,
2786- false ,
2787- false ,
2788- {
2784+ Report . changeReportPolicyAndInviteSubmitter ( {
2785+ report : expenseReport ,
2786+ parentReport : undefined ,
2787+ policy : createRandomPolicy ( Number ( 2 ) ) ,
2788+ currentUserAccountID : 1 ,
2789+ email : '' ,
2790+ hasViolationsParam : true ,
2791+ isChangePolicyTrainingModalDismissed : false ,
2792+ isASAPSubmitBetaEnabled : false ,
2793+ employeeList : {
27892794 [ adminEmail ] : { role : CONST . POLICY . ROLE . ADMIN } ,
27902795 } ,
2791- TestHelper . formatPhoneNumber ,
2792- undefined ,
2793- ) ;
2796+ formatPhoneNumber : TestHelper . formatPhoneNumber ,
2797+ isReportLastVisibleArchived : undefined ,
2798+ } ) ;
27942799 await waitForBatchedUpdates ( ) ;
27952800
27962801 // Then the expense report should not be archived anymore
@@ -2864,7 +2869,19 @@ describe('actions/Report', () => {
28642869 await waitForBatchedUpdates ( ) ;
28652870
28662871 // Call changeReportPolicyAndInviteSubmitter
2867- Report . changeReportPolicyAndInviteSubmitter ( expenseReport , newPolicy , 1 , '' , true , false , false , employeeList , TestHelper . formatPhoneNumber , false ) ;
2872+ Report . changeReportPolicyAndInviteSubmitter ( {
2873+ report : expenseReport ,
2874+ parentReport : undefined ,
2875+ policy : newPolicy ,
2876+ currentUserAccountID : 1 ,
2877+ email : '' ,
2878+ hasViolationsParam : true ,
2879+ isChangePolicyTrainingModalDismissed : false ,
2880+ isASAPSubmitBetaEnabled : false ,
2881+ employeeList,
2882+ formatPhoneNumber : TestHelper . formatPhoneNumber ,
2883+ isReportLastVisibleArchived : false ,
2884+ } ) ;
28682885 await waitForBatchedUpdates ( ) ;
28692886
28702887 // Simulate network failure
@@ -3051,7 +3068,7 @@ describe('actions/Report', () => {
30513068 type : CONST . REPORT . TYPE . EXPENSE ,
30523069 } ;
30533070 const policy = createRandomPolicy ( Number ( 1 ) ) ;
3054- Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3071+ Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
30553072 // eslint-disable-next-line @typescript-eslint/no-deprecated
30563073 expect ( buildNextStepNew ) . toHaveBeenCalledWith ( {
30573074 report,
@@ -3092,7 +3109,7 @@ describe('actions/Report', () => {
30923109 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , transaction ) ;
30933110 await waitForBatchedUpdates ( ) ;
30943111
3095- const { optimisticData, successData, failureData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3112+ const { optimisticData, successData, failureData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
30963113
30973114 // Find the transaction optimistic data
30983115 const transactionOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
@@ -3140,7 +3157,7 @@ describe('actions/Report', () => {
31403157 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , transaction ) ;
31413158 await waitForBatchedUpdates ( ) ;
31423159
3143- const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3160+ const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
31443161
31453162 // Should NOT find transaction optimistic data when currencies are the same
31463163 const transactionOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
@@ -3175,7 +3192,7 @@ describe('actions/Report', () => {
31753192 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , transaction ) ;
31763193 await waitForBatchedUpdates ( ) ;
31773194
3178- const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3195+ const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
31793196
31803197 // Should NOT find transaction optimistic data when transaction matches destination currency
31813198 const transactionOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ) ;
@@ -3223,7 +3240,7 @@ describe('actions/Report', () => {
32233240 await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ nonMatchingTransactionID } ` , nonMatchingTransaction ) ;
32243241 await waitForBatchedUpdates ( ) ;
32253242
3226- const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , policy , 1 , '' , false , true , undefined ) ;
3243+ const { optimisticData} = Report . buildOptimisticChangePolicyData ( report , undefined , policy , 1 , '' , false , true , undefined ) ;
32273244
32283245 // Should NOT find optimistic data for the matching transaction (USD matches USD destination)
32293246 const matchingOptimisticData = optimisticData . find ( ( data ) => data . key === `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ matchingTransactionID } ` ) ;
0 commit comments