@@ -130,6 +130,97 @@ describe('getReportPreviewAction', () => {
130130 ) . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ) ;
131131 } ) ;
132132
133+ it ( 'canSubmit should return false for manager who is not the submitter' , async ( ) => {
134+ const MANAGER_ACCOUNT_ID = 2 ;
135+ const MANAGER_EMAIL = 'manager@mail.com' ;
136+ const report : Report = {
137+ ...createRandomReport ( REPORT_ID , undefined ) ,
138+ type : CONST . REPORT . TYPE . EXPENSE ,
139+ ownerAccountID : CURRENT_USER_ACCOUNT_ID ,
140+ managerID : MANAGER_ACCOUNT_ID ,
141+ stateNum : CONST . REPORT . STATE_NUM . OPEN ,
142+ statusNum : CONST . REPORT . STATUS_NUM . OPEN ,
143+ isWaitingOnBankAccount : false ,
144+ } ;
145+
146+ const policy = createRandomPolicy ( 0 ) ;
147+ policy . autoReportingFrequency = CONST . POLICY . AUTO_REPORTING_FREQUENCIES . IMMEDIATE ;
148+ policy . type = CONST . POLICY . TYPE . CORPORATE ;
149+ if ( policy . harvesting ) {
150+ policy . harvesting . enabled = false ;
151+ }
152+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
153+ await Onyx . merge ( ONYXKEYS . SESSION , { email : MANAGER_EMAIL , accountID : MANAGER_ACCOUNT_ID } ) ;
154+ const transaction = {
155+ reportID : `${ REPORT_ID } ` ,
156+ amount : 100 ,
157+ merchant : 'Test Merchant' ,
158+ created : '2025-01-01' ,
159+ } as unknown as Transaction ;
160+
161+ const { result : isReportArchived } = renderHook ( ( ) => useReportIsArchived ( report ?. parentReportID ) ) ;
162+ await waitForBatchedUpdatesWithAct ( ) ;
163+
164+ expect (
165+ getReportPreviewAction ( {
166+ isReportArchived : isReportArchived . current ,
167+ currentUserAccountID : MANAGER_ACCOUNT_ID ,
168+ currentUserLogin : MANAGER_EMAIL ,
169+ report,
170+ policy,
171+ transactions : [ transaction ] ,
172+ bankAccountList : { } ,
173+ reportMetadata : undefined ,
174+ } ) ,
175+ ) . not . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ) ;
176+ } ) ;
177+
178+ it ( 'canSubmit should return false for admin who is not the submitter' , async ( ) => {
179+ const ADMIN_ACCOUNT_ID = 3 ;
180+ const ADMIN_EMAIL = 'admin@mail.com' ;
181+ const report : Report = {
182+ ...createRandomReport ( REPORT_ID , undefined ) ,
183+ type : CONST . REPORT . TYPE . EXPENSE ,
184+ ownerAccountID : CURRENT_USER_ACCOUNT_ID ,
185+ managerID : 2 ,
186+ stateNum : CONST . REPORT . STATE_NUM . OPEN ,
187+ statusNum : CONST . REPORT . STATUS_NUM . OPEN ,
188+ isWaitingOnBankAccount : false ,
189+ } ;
190+
191+ const policy = createRandomPolicy ( 0 ) ;
192+ policy . autoReportingFrequency = CONST . POLICY . AUTO_REPORTING_FREQUENCIES . IMMEDIATE ;
193+ policy . type = CONST . POLICY . TYPE . CORPORATE ;
194+ policy . role = CONST . POLICY . ROLE . ADMIN ;
195+ if ( policy . harvesting ) {
196+ policy . harvesting . enabled = false ;
197+ }
198+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
199+ await Onyx . merge ( ONYXKEYS . SESSION , { email : ADMIN_EMAIL , accountID : ADMIN_ACCOUNT_ID } ) ;
200+ const transaction = {
201+ reportID : `${ REPORT_ID } ` ,
202+ amount : 100 ,
203+ merchant : 'Test Merchant' ,
204+ created : '2025-01-01' ,
205+ } as unknown as Transaction ;
206+
207+ const { result : isReportArchived } = renderHook ( ( ) => useReportIsArchived ( report ?. parentReportID ) ) ;
208+ await waitForBatchedUpdatesWithAct ( ) ;
209+
210+ expect (
211+ getReportPreviewAction ( {
212+ isReportArchived : isReportArchived . current ,
213+ currentUserAccountID : ADMIN_ACCOUNT_ID ,
214+ currentUserLogin : ADMIN_EMAIL ,
215+ report,
216+ policy,
217+ transactions : [ transaction ] ,
218+ bankAccountList : { } ,
219+ reportMetadata : undefined ,
220+ } ) ,
221+ ) . not . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ) ;
222+ } ) ;
223+
133224 it ( 'canSubmit should return true for open report in instant submit policy with no approvers' , async ( ) => {
134225 const report : Report = {
135226 ...createRandomReport ( REPORT_ID , undefined ) ,
0 commit comments