Skip to content

Commit

Permalink
Merge pull request #53137 from tienifr/fix/34767
Browse files Browse the repository at this point in the history
Green dot disappears from LHN when paying one out of many unpaid reports
  • Loading branch information
cristipaval authored Mar 7, 2025
2 parents a857238 + e71dff4 commit 1247366
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {addSMSDomainIfPhoneNumber} from '@libs/PhoneNumber';
import {getPerDiemCustomUnit, getPolicy, getSubmitToAccountID, hasDependentTags, isControlPolicy, isPaidGroupPolicy, isPolicyAdmin, isSubmitAndClose} from '@libs/PolicyUtils';
import {
getAllReportActions,
getIOUReportIDFromReportActionPreview,
getLastVisibleAction,
getLastVisibleMessage,
getOriginalMessage,
Expand Down Expand Up @@ -7851,6 +7852,23 @@ function getReportFromHoldRequestsOnyxData(
};
}

function hasOutstandingChildRequest(chatReport: OnyxTypes.Report, excludedIOUReport: OnyxEntry<OnyxTypes.Report>, policyId?: string) {
const policy = getPolicy(policyId);
if (!policy?.achAccount?.bankAccountID) {
return false;
}
const reportActions = getAllReportActions(chatReport.reportID);
return !!Object.values(reportActions).find((action) => {
const iouReportID = getIOUReportIDFromReportActionPreview(action);
if (iouReportID === excludedIOUReport?.reportID) {
return false;
}
const iouReport = getReportOrDraftReport(iouReportID);
const transactions = getReportTransactions(iouReportID);
return canIOUBePaid(iouReport, chatReport, policy, transactions) || canIOUBePaid(iouReport, chatReport, policy, transactions, true);
});
}

function getPayMoneyRequestParams(
initialChatReport: OnyxTypes.Report,
iouReport: OnyxEntry<OnyxTypes.Report>,
Expand Down Expand Up @@ -7937,7 +7955,7 @@ function getPayMoneyRequestParams(
const optimisticChatReport = {
...chatReport,
lastReadTime: DateUtils.getDBTime(),
hasOutstandingChildRequest: false,
hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport, iouReport?.policyID),
iouReportID: null,
lastMessageText: getReportActionText(optimisticIOUReportAction),
lastMessageHtml: getReportActionHtml(optimisticIOUReportAction),
Expand Down

0 comments on commit 1247366

Please sign in to comment.