Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Thread - New line marker appeared incorrectly when mark as read is clicked #48279

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7218,7 +7218,7 @@ function shouldDisableThread(reportAction: OnyxInputOrEntry<ReportAction>, repor
);
}

function getAllAncestorReportActions(report: Report | null | undefined): Ancestor[] {
function getAllAncestorReportActions(report: Report | null | undefined, currentUpdatedReport?: OnyxEntry<Report>): Ancestor[] {
if (!report) {
return [];
}
Expand All @@ -7227,7 +7227,7 @@ function getAllAncestorReportActions(report: Report | null | undefined): Ancesto
let parentReportActionID = report.parentReportActionID;

while (parentReportID) {
const parentReport = getReportOrDraftReport(parentReportID);
const parentReport = currentUpdatedReport && currentUpdatedReport.reportID === parentReportID ? currentUpdatedReport : getReportOrDraftReport(parentReportID);
const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '-1');

if (
Expand Down
6 changes: 5 additions & 1 deletion src/pages/home/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ function ReportActionItemParentAction({
key: `${ONYXKEYS.COLLECTION.REPORT}${ancestorReportID}`,
callback: (val) => {
ancestorReports.current[ancestorReportID] = val;
setAllAncestors(ReportUtils.getAllAncestorReportActions(report));
// getAllAncestorReportActions use getReportOrDraftReport to get parent reports which gets the report from allReports that
// holds the report collection. However, allReports is not updated by the time this current callback is called.
// Therefore we need to pass the up-to-date report to getAllAncestorReportActions so that it uses the up-to-date report value
// to calculate, for instance, unread marker.
setAllAncestors(ReportUtils.getAllAncestorReportActions(report, val));
},
}),
);
Expand Down
Loading