@@ -20,6 +20,8 @@ const approverAccountID = 1111111;
2020const approverEmail = 'approver@policy.com' ;
2121const overlimitApproverAccountID = 222222 ;
2222const overlimitApproverEmail = 'overlimit@policy.com' ;
23+ const submitterAccountID = 333333 ;
24+ const submitterEmail = 'submitter@policy.com' ;
2325const policyID = 'A1B2C3' ;
2426const reportID = '123456789' ;
2527const reportID2 = '11111' ;
@@ -61,6 +63,12 @@ const searchResults: OnyxTypes.SearchResults = {
6163 displayName : 'Overlimit Approver' ,
6264 login : overlimitApproverEmail ,
6365 } ,
66+ [ submitterAccountID ] : {
67+ accountID : submitterAccountID ,
68+ avatar : 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png' ,
69+ displayName : 'Submitter' ,
70+ login : submitterEmail ,
71+ } ,
6472 } ,
6573 [ `policy_${ policyID } ` ] : {
6674 id : 'Admin' ,
@@ -98,6 +106,11 @@ const searchResults: OnyxTypes.SearchResults = {
98106 role : CONST . POLICY . ROLE . ADMIN ,
99107 submitsTo : approverEmail ,
100108 } ,
109+ [ submitterEmail ] : {
110+ email : submitterEmail ,
111+ role : CONST . POLICY . ROLE . USER ,
112+ submitsTo : adminEmail ,
113+ } ,
101114 } ,
102115 } ,
103116 [ `reportActions_${ reportID } ` ] : {
@@ -957,6 +970,29 @@ describe('SearchUIUtils', () => {
957970 expect ( action ) . toStrictEqual ( CONST . SEARCH . ACTION_TYPES . SUBMIT ) ;
958971 } ) ;
959972
973+ test ( 'Should return `View` action for transaction on policy with delayed submission and with violations when current user is submitter and the expense was submitted' , async ( ) => {
974+ await Onyx . merge ( ONYXKEYS . SESSION , { accountID : submitterAccountID } ) ;
975+ const localSearchResults = {
976+ ...searchResults . data ,
977+ [ `policy_${ policyID } ` ] : {
978+ ...searchResults . data [ `policy_${ policyID } ` ] ,
979+ role : CONST . POLICY . ROLE . USER ,
980+ } ,
981+ [ `report_${ reportID2 } ` ] : {
982+ ...searchResults . data [ `report_${ reportID2 } ` ] ,
983+ accountID : submitterAccountID ,
984+ ownerAccountID : submitterAccountID ,
985+ } ,
986+ [ `transactions_${ transactionID2 } ` ] : {
987+ ...searchResults . data [ `transactions_${ transactionID2 } ` ] ,
988+ accountID : submitterAccountID ,
989+ managerID : adminAccountID ,
990+ } ,
991+ } ;
992+ expect ( SearchUIUtils . getAction ( localSearchResults , allViolations , `report_${ reportID2 } ` ) ) . toStrictEqual ( CONST . SEARCH . ACTION_TYPES . VIEW ) ;
993+ expect ( SearchUIUtils . getAction ( localSearchResults , allViolations , `transactions_${ transactionID2 } ` ) ) . toStrictEqual ( CONST . SEARCH . ACTION_TYPES . VIEW ) ;
994+ } ) ;
995+
960996 test ( 'Should return `Review` action for transaction on policy with delayed submission and with violations' , ( ) => {
961997 let action = SearchUIUtils . getAction ( searchResults . data , allViolations , `report_${ reportID2 } ` ) ;
962998 expect ( action ) . toStrictEqual ( CONST . SEARCH . ACTION_TYPES . REVIEW ) ;
0 commit comments