@@ -383,6 +383,113 @@ describe('getSecondaryAction', () => {
383383 expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( true ) ;
384384 } ) ;
385385
386+ it ( 'includes UNAPPROVE option for admin on finally approved report' , ( ) => {
387+ const report = {
388+ reportID : REPORT_ID ,
389+ type : CONST . REPORT . TYPE . EXPENSE ,
390+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
391+ stateNum : CONST . REPORT . STATE_NUM . APPROVED ,
392+ statusNum : CONST . REPORT . STATUS_NUM . APPROVED ,
393+ managerID : MANAGER_ACCOUNT_ID ,
394+ } as unknown as Report ;
395+ const policy = {
396+ approver : APPROVER_EMAIL ,
397+ role : CONST . POLICY . ROLE . ADMIN ,
398+ } as unknown as Policy ;
399+
400+ const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy} ) ;
401+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( true ) ;
402+ } ) ;
403+
404+ it ( 'includes UNAPPROVE option for manager on finally approved report' , ( ) => {
405+ const report = {
406+ reportID : REPORT_ID ,
407+ type : CONST . REPORT . TYPE . EXPENSE ,
408+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
409+ stateNum : CONST . REPORT . STATE_NUM . APPROVED ,
410+ statusNum : CONST . REPORT . STATUS_NUM . APPROVED ,
411+ managerID : EMPLOYEE_ACCOUNT_ID ,
412+ } as unknown as Report ;
413+ const policy = {
414+ approver : APPROVER_EMAIL ,
415+ } as unknown as Policy ;
416+
417+ const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy} ) ;
418+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( true ) ;
419+ } ) ;
420+
421+ it ( 'does not include UNAPPROVE option for non-admin, non-manager on finally approved report' , ( ) => {
422+ const report = {
423+ reportID : REPORT_ID ,
424+ type : CONST . REPORT . TYPE . EXPENSE ,
425+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
426+ stateNum : CONST . REPORT . STATE_NUM . APPROVED ,
427+ statusNum : CONST . REPORT . STATUS_NUM . APPROVED ,
428+ managerID : MANAGER_ACCOUNT_ID ,
429+ } as unknown as Report ;
430+ const policy = {
431+ approver : APPROVER_EMAIL ,
432+ } as unknown as Policy ;
433+
434+ const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy} ) ;
435+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( false ) ;
436+ } ) ;
437+
438+ it ( 'does not include UNAPPROVE option for non-approved report' , ( ) => {
439+ const report = {
440+ reportID : REPORT_ID ,
441+ type : CONST . REPORT . TYPE . EXPENSE ,
442+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
443+ stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
444+ statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
445+ managerID : EMPLOYEE_ACCOUNT_ID ,
446+ } as unknown as Report ;
447+ const policy = {
448+ approver : EMPLOYEE_EMAIL ,
449+ role : CONST . POLICY . ROLE . ADMIN ,
450+ } as unknown as Policy ;
451+
452+ const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy} ) ;
453+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( false ) ;
454+ } ) ;
455+
456+ it ( 'does not include UNAPPROVE option for settled report' , ( ) => {
457+ const report = {
458+ reportID : REPORT_ID ,
459+ type : CONST . REPORT . TYPE . EXPENSE ,
460+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
461+ stateNum : CONST . REPORT . STATE_NUM . APPROVED ,
462+ statusNum : CONST . REPORT . STATUS_NUM . REIMBURSED ,
463+ managerID : EMPLOYEE_ACCOUNT_ID ,
464+ } as unknown as Report ;
465+ const policy = {
466+ approver : EMPLOYEE_EMAIL ,
467+ role : CONST . POLICY . ROLE . ADMIN ,
468+ } as unknown as Policy ;
469+
470+ const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy} ) ;
471+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( false ) ;
472+ } ) ;
473+
474+ it ( 'does not include UNAPPROVE option for payment processing report' , ( ) => {
475+ const report = {
476+ reportID : REPORT_ID ,
477+ type : CONST . REPORT . TYPE . EXPENSE ,
478+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
479+ stateNum : CONST . REPORT . STATE_NUM . APPROVED ,
480+ statusNum : CONST . REPORT . STATUS_NUM . APPROVED ,
481+ managerID : EMPLOYEE_ACCOUNT_ID ,
482+ isWaitingOnBankAccount : true ,
483+ } as unknown as Report ;
484+ const policy = {
485+ approver : EMPLOYEE_EMAIL ,
486+ role : CONST . POLICY . ROLE . ADMIN ,
487+ } as unknown as Policy ;
488+
489+ const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy} ) ;
490+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . UNAPPROVE ) ) . toBe ( false ) ;
491+ } ) ;
492+
386493 it ( 'includes CANCEL_PAYMENT option for report paid elsewhere' , ( ) => {
387494 const report = {
388495 reportID : REPORT_ID ,
0 commit comments