@@ -30,6 +30,8 @@ const MOCK_REPORT_ACTION: ReportAction = {
3030const MOCK_TRANSACTION : Transaction = createRandomTransaction ( 0 ) ;
3131
3232const MOCK_DRAFT_REPORT_ACTION = DebugUtils . onyxDataToString ( MOCK_REPORT_ACTION ) ;
33+ const RORY_EMAIL = 'rory@email.com' ;
34+ const RORY_ACCOUNT_ID = 5 ;
3335
3436const MOCK_CONST_ENUM = {
3537 foo : 'foo' ,
@@ -1006,7 +1008,7 @@ describe('DebugUtils', () => {
10061008 Onyx . clear ( ) ;
10071009 } ) ;
10081010 it ( 'returns undefined reason when report is not defined' , ( ) => {
1009- const { reason} = DebugUtils . getReasonAndReportActionForGBRInLHNRow ( undefined ) ?? { } ;
1011+ const { reason} = DebugUtils . getReasonAndReportActionForGBRInLHNRow ( undefined , RORY_EMAIL , RORY_ACCOUNT_ID ) ?? { } ;
10101012 expect ( reason ) . toBeUndefined ( ) ;
10111013 } ) ;
10121014 it ( 'returns correct reason when report has a join request' , async ( ) => {
@@ -1024,50 +1026,70 @@ describe('DebugUtils', () => {
10241026 } ;
10251027 await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } 1` , MOCK_REPORT_ACTIONS ) ;
10261028 const { reason} =
1027- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1028- reportID : '1' ,
1029- } ) ?? { } ;
1029+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1030+ {
1031+ reportID : '1' ,
1032+ } ,
1033+ RORY_EMAIL ,
1034+ RORY_ACCOUNT_ID ,
1035+ ) ?? { } ;
10301036 expect ( reason ) . toBe ( 'debug.reasonGBR.hasJoinRequest' ) ;
10311037 } ) ;
10321038 it ( 'returns correct reason when report is unread with mention' , ( ) => {
10331039 const { reason} =
1034- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1035- reportID : '1' ,
1036- lastMentionedTime : '2024-08-10 18:70:44.171' ,
1037- lastReadTime : '2024-08-08 18:70:44.171' ,
1038- } ) ?? { } ;
1040+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1041+ {
1042+ reportID : '1' ,
1043+ lastMentionedTime : '2024-08-10 18:70:44.171' ,
1044+ lastReadTime : '2024-08-08 18:70:44.171' ,
1045+ } ,
1046+ RORY_EMAIL ,
1047+ RORY_ACCOUNT_ID ,
1048+ ) ?? { } ;
10391049 expect ( reason ) . toBe ( 'debug.reasonGBR.isUnreadWithMention' ) ;
10401050 } ) ;
10411051 it ( 'returns correct reason when report has a task which is waiting for assignee to complete it' , async ( ) => {
10421052 await Onyx . set ( ONYXKEYS . SESSION , { accountID : 12345 } ) ;
10431053 const { reason} =
1044- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1045- reportID : '1' ,
1046- type : CONST . REPORT . TYPE . TASK ,
1047- hasParentAccess : false ,
1048- managerID : 12345 ,
1049- stateNum : CONST . REPORT . STATE_NUM . OPEN ,
1050- statusNum : CONST . REPORT . STATUS_NUM . OPEN ,
1051- } ) ?? { } ;
1054+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1055+ {
1056+ reportID : '1' ,
1057+ type : CONST . REPORT . TYPE . TASK ,
1058+ hasParentAccess : false ,
1059+ managerID : 12345 ,
1060+ stateNum : CONST . REPORT . STATE_NUM . OPEN ,
1061+ statusNum : CONST . REPORT . STATUS_NUM . OPEN ,
1062+ } ,
1063+ RORY_EMAIL ,
1064+ RORY_ACCOUNT_ID ,
1065+ ) ?? { } ;
10521066 expect ( reason ) . toBe ( 'debug.reasonGBR.isWaitingForAssigneeToCompleteAction' ) ;
10531067 } ) ;
10541068 it ( 'returns correct reason when report has a child report awaiting action from the user' , ( ) => {
10551069 const { reason} =
1056- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1057- reportID : '1' ,
1058- hasOutstandingChildRequest : true ,
1059- } ) ?? { } ;
1070+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1071+ {
1072+ reportID : '1' ,
1073+ hasOutstandingChildRequest : true ,
1074+ } ,
1075+ RORY_EMAIL ,
1076+ RORY_ACCOUNT_ID ,
1077+ ) ?? { } ;
10601078 expect ( reason ) . toBe ( 'debug.reasonGBR.hasChildReportAwaitingAction' ) ;
10611079 } ) ;
10621080 it ( 'returns undefined reason when report has no GBR' , ( ) => {
10631081 const { reason} =
1064- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1065- reportID : '1' ,
1066- } ) ?? { } ;
1082+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1083+ {
1084+ reportID : '1' ,
1085+ } ,
1086+ RORY_EMAIL ,
1087+ RORY_ACCOUNT_ID ,
1088+ ) ?? { } ;
10671089 expect ( reason ) . toBeUndefined ( ) ;
10681090 } ) ;
10691091 it ( 'returns undefined reportAction when report is not defined' , ( ) => {
1070- const { reportAction} = DebugUtils . getReasonAndReportActionForGBRInLHNRow ( undefined ) ?? { } ;
1092+ const { reportAction} = DebugUtils . getReasonAndReportActionForGBRInLHNRow ( undefined , RORY_EMAIL , RORY_ACCOUNT_ID ) ?? { } ;
10711093 expect ( reportAction ) . toBeUndefined ( ) ;
10721094 } ) ;
10731095 it ( 'returns the report action which is a join request' , async ( ) => {
@@ -1091,9 +1113,13 @@ describe('DebugUtils', () => {
10911113 } ;
10921114 await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } 1` , MOCK_REPORT_ACTIONS ) ;
10931115 const { reportAction} =
1094- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1095- reportID : '1' ,
1096- } ) ?? { } ;
1116+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1117+ {
1118+ reportID : '1' ,
1119+ } ,
1120+ RORY_EMAIL ,
1121+ RORY_ACCOUNT_ID ,
1122+ ) ?? { } ;
10971123 expect ( reportAction ) . toMatchObject ( MOCK_REPORT_ACTIONS [ '1' ] ) ;
10981124 } ) ;
10991125 it ( 'returns the report action which is awaiting action' , async ( ) => {
@@ -1160,14 +1186,18 @@ describe('DebugUtils', () => {
11601186 } ,
11611187 } ) ;
11621188 // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
1163- const { reportAction} = DebugUtils . getReasonAndReportActionForGBRInLHNRow ( MOCK_REPORTS [ `${ ONYXKEYS . COLLECTION . REPORT } 1` ] as Report ) ?? { } ;
1189+ const { reportAction} = DebugUtils . getReasonAndReportActionForGBRInLHNRow ( MOCK_REPORTS [ `${ ONYXKEYS . COLLECTION . REPORT } 1` ] as Report , RORY_EMAIL , RORY_ACCOUNT_ID ) ?? { } ;
11641190 expect ( reportAction ) . toMatchObject ( MOCK_REPORT_ACTIONS [ '1' ] ) ;
11651191 } ) ;
11661192 it ( 'returns undefined report action when report has no GBR' , ( ) => {
11671193 const { reportAction} =
1168- DebugUtils . getReasonAndReportActionForGBRInLHNRow ( {
1169- reportID : '1' ,
1170- } ) ?? { } ;
1194+ DebugUtils . getReasonAndReportActionForGBRInLHNRow (
1195+ {
1196+ reportID : '1' ,
1197+ } ,
1198+ RORY_EMAIL ,
1199+ RORY_ACCOUNT_ID ,
1200+ ) ?? { } ;
11711201 expect ( reportAction ) . toBeUndefined ( ) ;
11721202 } ) ;
11731203 } ) ;
0 commit comments