@@ -61,6 +61,7 @@ import {addSMSDomainIfPhoneNumber} from '@libs/PhoneNumber';
61
61
import { getPerDiemCustomUnit , getPolicy , getSubmitToAccountID , hasDependentTags , isControlPolicy , isPaidGroupPolicy , isPolicyAdmin , isSubmitAndClose } from '@libs/PolicyUtils' ;
62
62
import {
63
63
getAllReportActions ,
64
+ getIOUReportIDFromReportActionPreview ,
64
65
getLastVisibleAction ,
65
66
getLastVisibleMessage ,
66
67
getOriginalMessage ,
@@ -7851,6 +7852,23 @@ function getReportFromHoldRequestsOnyxData(
7851
7852
} ;
7852
7853
}
7853
7854
7855
+ function hasOutstandingChildRequest ( chatReport : OnyxTypes . Report , excludedIOUReport : OnyxEntry < OnyxTypes . Report > , policyId ?: string ) {
7856
+ const policy = getPolicy ( policyId ) ;
7857
+ if ( ! policy ?. achAccount ?. bankAccountID ) {
7858
+ return false ;
7859
+ }
7860
+ const reportActions = getAllReportActions ( chatReport . reportID ) ;
7861
+ return ! ! Object . values ( reportActions ) . find ( ( action ) => {
7862
+ const iouReportID = getIOUReportIDFromReportActionPreview ( action ) ;
7863
+ if ( iouReportID === excludedIOUReport ?. reportID ) {
7864
+ return false ;
7865
+ }
7866
+ const iouReport = getReportOrDraftReport ( iouReportID ) ;
7867
+ const transactions = getReportTransactions ( iouReportID ) ;
7868
+ return canIOUBePaid ( iouReport , chatReport , policy , transactions ) || canIOUBePaid ( iouReport , chatReport , policy , transactions , true ) ;
7869
+ } ) ;
7870
+ }
7871
+
7854
7872
function getPayMoneyRequestParams (
7855
7873
initialChatReport : OnyxTypes . Report ,
7856
7874
iouReport : OnyxEntry < OnyxTypes . Report > ,
@@ -7937,7 +7955,7 @@ function getPayMoneyRequestParams(
7937
7955
const optimisticChatReport = {
7938
7956
...chatReport ,
7939
7957
lastReadTime : DateUtils . getDBTime ( ) ,
7940
- hasOutstandingChildRequest : false ,
7958
+ hasOutstandingChildRequest : hasOutstandingChildRequest ( chatReport , iouReport , iouReport ?. policyID ) ,
7941
7959
iouReportID : null ,
7942
7960
lastMessageText : getReportActionText ( optimisticIOUReportAction ) ,
7943
7961
lastMessageHtml : getReportActionHtml ( optimisticIOUReportAction ) ,
0 commit comments