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: parent thread disappears in LHN when deleting the thread first chat #27410

Merged
merged 8 commits into from
Sep 19, 2023
17 changes: 15 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,18 @@ function canAccessReport(report, policies, betas, allReportActions) {

return true;
}
/**
* Check if the report is the parent report of the currently viewed report or at least one child report has report action
* @param {Object} report
* @param {String} currentReportId
* @returns {Boolean}
*/
function shouldHideReport(report, currentReportId) {
Julesssss marked this conversation as resolved.
Show resolved Hide resolved
const parentReport = getParentReport(getReport(currentReportId));
const reportActions = ReportActionsUtils.getAllReportActions(report.reportID);
const isChildReportHasComment = _.some(reportActions, (reportAction) => (reportAction.childVisibleActionCount || 0) > 0);
return parentReport.reportID !== report.reportID && !isChildReportHasComment;
}

/**
* Takes several pieces of data from Onyx and evaluates if a report should be shown in the option list (either when searching
Expand Down Expand Up @@ -2847,9 +2859,10 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas,

const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID);
const isEmptyChat = !report.lastMessageText && !report.lastMessageTranslationKey && !lastVisibleMessage.lastMessageText && !lastVisibleMessage.lastMessageTranslationKey;
const canHideReport = shouldHideReport(report, currentReportId);

// Hide only chat threads that haven't been commented on (other threads are actionable)
if (isChatThread(report) && isEmptyChat) {
if (isChatThread(report) && canHideReport && isEmptyChat) {
return false;
}

Expand All @@ -2875,7 +2888,7 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas,
}

// Hide chats between two users that haven't been commented on from the LNH
if (excludeEmptyChats && isEmptyChat && isChatReport(report) && !isChatRoom(report) && !isPolicyExpenseChat(report)) {
if (excludeEmptyChats && isEmptyChat && isChatReport(report) && !isChatRoom(report) && !isPolicyExpenseChat(report) && canHideReport) {
return false;
}

Expand Down