@@ -23,6 +23,8 @@ const PERSONAL_DETAILS = {
2323} ;
2424
2525const REPORT_ID = 1 ;
26+ const CHAT_REPORT_ID = 2 ;
27+ const POLICY_ID = 3 ;
2628
2729// This keeps the error "@rnmapbox/maps native code not available." from causing the tests to fail
2830jest . mock ( '@components/ConfirmedRoute.tsx' ) ;
@@ -557,4 +559,38 @@ describe('getTransactionThreadPrimaryAction', () => {
557559 } ) ,
558560 ) . toBe ( '' ) ;
559561 } ) ;
562+
563+ it ( 'should return PAY if paid as business and the payer is the policy admin' , async ( ) => {
564+ const report = {
565+ reportID : REPORT_ID ,
566+ type : CONST . REPORT . TYPE . INVOICE ,
567+ ownerAccountID : CURRENT_USER_ACCOUNT_ID ,
568+ parentReportID : CHAT_REPORT_ID ,
569+ } as unknown as Report ;
570+ const parentReport = {
571+ reportID : CHAT_REPORT_ID ,
572+ invoiceReceiver : {
573+ type : CONST . REPORT . INVOICE_RECEIVER_TYPE . BUSINESS ,
574+ policyID : POLICY_ID ,
575+ } ,
576+ } as unknown as Report ;
577+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
578+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ CHAT_REPORT_ID } ` , parentReport ) ;
579+ const invoiceReceiverPolicy = {
580+ role : CONST . POLICY . ROLE . ADMIN ,
581+ } ;
582+ const transaction = {
583+ reportID : `${ REPORT_ID } ` ,
584+ } as unknown as Transaction ;
585+ expect (
586+ getReportPrimaryAction ( {
587+ report,
588+ chatReport,
589+ reportTransactions : [ transaction ] ,
590+ violations : { } ,
591+ policy : { } as Policy ,
592+ invoiceReceiverPolicy : invoiceReceiverPolicy as Policy ,
593+ } ) ,
594+ ) . toBe ( CONST . REPORT . PRIMARY_ACTIONS . PAY ) ;
595+ } ) ;
560596} ) ;
0 commit comments