Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/libs/actions/OnyxDerived/configs/reportAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ export default createOnyxDerivedValueConfig({

// When an IOU report changes, we need to re-evaluate its parent chat report as well.
const parentChatReportIDsToUpdate = new Set<string>();
dataToIterate.forEach((reportKey) => {
for (const reportKey of dataToIterate) {
const report = reports[reportKey];
if (report?.chatReportID && report.reportID !== report.chatReportID) {
parentChatReportIDsToUpdate.add(`${ONYXKEYS.COLLECTION.REPORT}${report.chatReportID}`);
}
});
}
if (parentChatReportIDsToUpdate.size > 0) {
dataToIterate.push(...Array.from(parentChatReportIDsToUpdate));
}
Expand Down Expand Up @@ -228,9 +228,9 @@ export default createOnyxDerivedValueConfig({

// Propagate errors from IOU reports to their parent chat reports.
const chatReportIDsWithErrors = new Set<string>();
Object.values(reports).forEach((report) => {
for (const report of Object.values(reports)) {
if (!report?.reportID) {
return;
continue;
}

// If this is an IOU report and its calculated attributes have an error,
Expand All @@ -239,14 +239,15 @@ export default createOnyxDerivedValueConfig({
if (report.chatReportID && report.reportID !== report.chatReportID && attributes?.brickRoadStatus === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) {
chatReportIDsWithErrors.add(report.chatReportID);
}
});
}

// Apply the error status to the parent chat reports.
chatReportIDsWithErrors.forEach((chatReportID) => {
if (reportAttributes[chatReportID]) {
reportAttributes[chatReportID].brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
for (const chatReportID of chatReportIDsWithErrors) {
if (!reportAttributes[chatReportID]) {
continue;
}
});
reportAttributes[chatReportID].brickRoadStatus = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
}

// mark the report attributes as fully computed after first iteration to avoid unnecessary recomputation on all objects
if (!Object.keys(reportUpdates).length && Object.keys(reports ?? {}).length > 0 && !isFullyComputed) {
Expand Down
Loading