@@ -103,22 +103,14 @@ describe('canEditFieldOfMoneyRequest', () => {
103103 return waitForBatchedUpdates ( ) ;
104104 } ) ;
105105
106- it ( 'should return false for invoice report action if it is not outstanding report' , async ( ) => {
106+ // Then the user should be able to move the invoice to the outstanding expense report
107+ it ( 'should return true for invoice report action given that there is a minimum of one outstanding report' , async ( ) => {
107108 const outstandingReportsByPolicyID = await OnyxUtils . get ( ONYXKEYS . DERIVED . OUTSTANDING_REPORTS_BY_POLICY_ID ) ;
108109
109110 const canEditReportField = canEditFieldOfMoneyRequest ( reportAction , CONST . EDIT_REQUEST_FIELD . REPORT , undefined , undefined , outstandingReportsByPolicyID ) ;
110- expect ( canEditReportField ) . toBe ( false ) ;
111- } ) ;
112-
113- it ( 'should return true for invoice report action when there are outstanding reports' , async ( ) => {
114- await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ IOUReportID } ` , outstandingExpenseReport ) ;
115- await waitForBatchedUpdates ( ) ;
116- const outstandingReportsByPolicyID = await OnyxUtils . get ( ONYXKEYS . DERIVED . OUTSTANDING_REPORTS_BY_POLICY_ID ) ;
117-
118- const canEditReportField = canEditFieldOfMoneyRequest ( reportAction , CONST . EDIT_REQUEST_FIELD . REPORT , undefined , undefined , outstandingReportsByPolicyID ) ;
119-
120111 expect ( canEditReportField ) . toBe ( true ) ;
121112 } ) ;
113+
122114 } ) ;
123115
124116 describe ( 'type is expense' , ( ) => {
@@ -260,6 +252,21 @@ describe('canEditFieldOfMoneyRequest', () => {
260252 // Then they should not be able to move the expense since there's only one outstanding report
261253 expect ( canEditReportField ) . toBe ( false ) ;
262254 } ) ;
255+
256+ it ( 'should return false when the expense report is not outstanding report' , async ( ) => {
257+ // Given that there are multiple outstanding expense reports in the same policy
258+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ IOUReportID } ` , { ...expenseReport , stateNum : CONST . REPORT . STATE_NUM . APPROVED , statusNum : CONST . REPORT . STATUS_NUM . APPROVED } ) ;
259+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ EXPENSE_OUTSTANDING_REPORT_1_ID } ` , outstandingExpenseReport1 ) ;
260+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ EXPENSE_OUTSTANDING_REPORT_2_ID } ` , outstandingExpenseReport2 ) ;
261+ await waitForBatchedUpdates ( ) ;
262+ const outstandingReportsByPolicyID = await OnyxUtils . get ( ONYXKEYS . DERIVED . OUTSTANDING_REPORTS_BY_POLICY_ID ) ;
263+
264+ // When the submitter tries to move an expense between reports
265+ const canEditReportField = canEditFieldOfMoneyRequest ( reportAction , CONST . EDIT_REQUEST_FIELD . REPORT , undefined , undefined , outstandingReportsByPolicyID ) ;
266+
267+ // Then they should be able to move the expense since there are multiple outstanding expense reports
268+ expect ( canEditReportField ) . toBe ( false ) ;
269+ } ) ;
263270 } ) ;
264271 } ) ;
265272} ) ;
0 commit comments