@@ -13,8 +13,11 @@ import ONYXKEYS from '@src/ONYXKEYS';
1313import type { Attendee } from '@src/types/onyx/IOU' ;
1414import type { ReportCollectionDataSet } from '@src/types/onyx/Report' ;
1515import * as TransactionUtils from '../../src/libs/TransactionUtils' ;
16- import type { RecentWaypoint , Report , ReportAction , ReportActions , Transaction } from '../../src/types/onyx' ;
17- import { createRandomReport } from '../utils/collections/reports' ;
16+ import type { PersonalDetails , RecentWaypoint , Report , ReportAction , ReportActions , Transaction } from '../../src/types/onyx' ;
17+ import createRandomPolicy from '../utils/collections/policies' ;
18+ import createRandomPolicyCategories from '../utils/collections/policyCategory' ;
19+ import { createExpenseReport , createRandomReport } from '../utils/collections/reports' ;
20+ import getOnyxValue from '../utils/getOnyxValue' ;
1821import waitForBatchedUpdates from '../utils/waitForBatchedUpdates' ;
1922
2023function generateTransaction ( values : Partial < Transaction > = { } ) : Transaction {
@@ -575,6 +578,40 @@ describe('Transaction', () => {
575578 expect ( report ?. total ) . toBe ( oldExpenseReport . total ) ;
576579 expect ( report ?. nonReimbursableTotal ) . toBe ( oldExpenseReport . nonReimbursableTotal ) ;
577580 } ) ;
581+
582+ it ( 'should show "waiting for you to submit expense" next step message when moving expense to a new report ' , async ( ) => {
583+ const policyID = '12346' ;
584+ const oldExpenseReportID = '5' ;
585+
586+ const transaction = generateTransaction ( { reportID : oldExpenseReportID } ) ;
587+
588+ const newOpenReport = { ...createExpenseReport ( 6334 ) , policyID, stateNum : CONST . REPORT . STATE_NUM . OPEN , statusNum : CONST . REPORT . STATUS_NUM . OPEN , ownerAccountID : CURRENT_USER_ID } ;
589+
590+ const policy = { ...createRandomPolicy ( Number ( policyID ) ) , harvesting : { enabled : false } , autoReportingFrequency : CONST . POLICY . AUTO_REPORTING_FREQUENCIES . IMMEDIATE } ;
591+
592+ const policyCategories = createRandomPolicyCategories ( 5 ) ;
593+
594+ const userPersonalDetails : Record < number , PersonalDetails > = {
595+ [ CURRENT_USER_ID ] : {
596+ login : 'test@gmail.com' ,
597+ accountID : CURRENT_USER_ID ,
598+ displayName : 'You' ,
599+ } ,
600+ } ;
601+
602+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transaction . transactionID } ` , transaction ) ;
603+ await Onyx . merge ( `${ ONYXKEYS . PERSONAL_DETAILS_LIST } ` , userPersonalDetails ) ;
604+
605+ changeTransactionsReport ( [ transaction . transactionID ] , false , CURRENT_USER_ID , 'test@gmail.com' , newOpenReport , policy , undefined , policyCategories ) ;
606+
607+ await waitForBatchedUpdates ( ) ;
608+
609+ const nextStep = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . NEXT_STEP } ${ newOpenReport . reportID } ` ) ;
610+
611+ const nextStepMessage = nextStep ?. message ?. map ( ( part ) => part . text ) . join ( '' ) ;
612+
613+ expect ( nextStepMessage ) . toEqual ( 'Waiting for You to submit %expenses.' ) ;
614+ } ) ;
578615 } ) ;
579616
580617 describe ( 'getAllNonDeletedTransactions' , ( ) => {
0 commit comments