@@ -19,6 +19,8 @@ import {translate} from '@libs/Localize';
1919import getReportURLForCurrentContext from '@libs/Navigation/helpers/getReportURLForCurrentContext' ;
2020import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute' ;
2121import Navigation from '@libs/Navigation/Navigation' ;
22+ // eslint-disable-next-line no-restricted-syntax
23+ import * as PolicyUtils from '@libs/PolicyUtils' ;
2224import { getOriginalMessage , getReportAction , isWhisperAction } from '@libs/ReportActionsUtils' ;
2325import { buildReportNameFromParticipantNames , computeReportName , getGroupChatName , getPolicyExpenseChatName , getReportName } from '@libs/ReportNameUtils' ;
2426import type { OptionData } from '@libs/ReportUtils' ;
@@ -189,6 +191,14 @@ jest.mock('@libs/Navigation/Navigation', () => ({
189191 } ,
190192} ) ) ;
191193
194+ jest . mock ( '@libs/PolicyUtils' , ( ) => ( {
195+ ...jest . requireActual < typeof PolicyUtils > ( '@libs/PolicyUtils' ) ,
196+ isPolicyAdmin : jest . fn ( ) . mockImplementation ( ( policy ?: Policy ) => policy ?. role === 'admin' ) ,
197+ isPaidGroupPolicy : jest . fn ( ) . mockImplementation ( ( policy ?: Policy ) => policy ?. type === 'corporate' || policy ?. type === 'team' ) ,
198+ } ) ) ;
199+
200+ const mockedPolicyUtils = PolicyUtils as jest . Mocked < typeof PolicyUtils > ;
201+
192202const testDate = DateUtils . getDBTime ( ) ;
193203const currentUserEmail = 'bjorn@vikings.net' ;
194204const currentUserAccountID = 5 ;
@@ -2915,6 +2925,7 @@ describe('ReportUtils', () => {
29152925 type : CONST . REPORT . TYPE . EXPENSE ,
29162926 ownerAccountID : currentUserAccountID ,
29172927 } ;
2928+ mockedPolicyUtils . isPaidGroupPolicy . mockReturnValue ( true ) ;
29182929 const moneyRequestOptions = temporary_getMoneyRequestOptions ( report , undefined , [ currentUserAccountID ] ) ;
29192930 expect ( moneyRequestOptions . length ) . toBe ( 2 ) ;
29202931 expect ( moneyRequestOptions . includes ( CONST . IOU . TYPE . SUBMIT ) ) . toBe ( true ) ;
@@ -6096,6 +6107,8 @@ describe('ReportUtils', () => {
60966107 } ;
60976108 await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ report . reportID } ` , report ) ;
60986109
6110+ mockedPolicyUtils . isPaidGroupPolicy . mockReturnValue ( true ) ;
6111+
60996112 // When it's checked if the transactions can be added
61006113 // Simulate how components determined if a report is archived by using this hook
61016114 const { result : isReportArchived } = renderHook ( ( ) => useReportIsArchived ( report ?. reportID ) ) ;
@@ -6114,6 +6127,8 @@ describe('ReportUtils', () => {
61146127 } ;
61156128 await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ report . reportID } ` , report ) ;
61166129
6130+ mockedPolicyUtils . isPaidGroupPolicy . mockReturnValue ( true ) ;
6131+
61176132 const result = canAddTransaction ( report , false ) ;
61186133
61196134 // Then the result is false
@@ -6158,6 +6173,8 @@ describe('ReportUtils', () => {
61586173
61596174 const { result : isReportArchived } = renderHook ( ( ) => useReportIsArchived ( report ?. reportID ) ) ;
61606175
6176+ mockedPolicyUtils . isPaidGroupPolicy . mockReturnValue ( true ) ;
6177+
61616178 // If the canAddTransaction is used for the case of adding expense into the report
61626179 const result = canAddTransaction ( report , isReportArchived . current ) ;
61636180
0 commit comments