Skip to content

Commit 1247366

Browse files
authored
Merge pull request Expensify#53137 from tienifr/fix/34767
Green dot disappears from LHN when paying one out of many unpaid reports
2 parents a857238 + e71dff4 commit 1247366

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/libs/actions/IOU.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import {addSMSDomainIfPhoneNumber} from '@libs/PhoneNumber';
6161
import {getPerDiemCustomUnit, getPolicy, getSubmitToAccountID, hasDependentTags, isControlPolicy, isPaidGroupPolicy, isPolicyAdmin, isSubmitAndClose} from '@libs/PolicyUtils';
6262
import {
6363
getAllReportActions,
64+
getIOUReportIDFromReportActionPreview,
6465
getLastVisibleAction,
6566
getLastVisibleMessage,
6667
getOriginalMessage,
@@ -7851,6 +7852,23 @@ function getReportFromHoldRequestsOnyxData(
78517852
};
78527853
}
78537854

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+
78547872
function getPayMoneyRequestParams(
78557873
initialChatReport: OnyxTypes.Report,
78567874
iouReport: OnyxEntry<OnyxTypes.Report>,
@@ -7937,7 +7955,7 @@ function getPayMoneyRequestParams(
79377955
const optimisticChatReport = {
79387956
...chatReport,
79397957
lastReadTime: DateUtils.getDBTime(),
7940-
hasOutstandingChildRequest: false,
7958+
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport, iouReport?.policyID),
79417959
iouReportID: null,
79427960
lastMessageText: getReportActionText(optimisticIOUReportAction),
79437961
lastMessageHtml: getReportActionHtml(optimisticIOUReportAction),

0 commit comments

Comments
 (0)