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 paid system message thread does not show up on LHN #44594

9 changes: 4 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1481,10 +1481,10 @@ function isOneTransactionReport(reportID: string): boolean {
/**
* Checks if a report is a transaction thread associated with a report that has only one transaction
*/
function isOneTransactionThread(reportID: string, parentReportID: string): boolean {
function isOneTransactionThread(reportID: string, parentReportID: string, threadParentReportAction: OnyxEntry<ReportAction>): boolean {
const parentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`] ?? ([] as ReportAction[]);
const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(parentReportID, parentReportActions);
return reportID === transactionThreadReportID;
return reportID === transactionThreadReportID && !ReportActionsUtils.isSentMoneyReportAction(threadParentReportAction);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the function to return false for sent money action so we can continue the review immediately after it comes off hold.

}

/**
Expand Down Expand Up @@ -5413,6 +5413,7 @@ function shouldReportBeInOptionList({
// Optionally exclude reports that do not belong to currently active workspace

const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number);
const parentReportAction = ReportActionsUtils.getParentReportAction(report);

if (
!report?.reportID ||
Expand Down Expand Up @@ -5444,7 +5445,7 @@ function shouldReportBeInOptionList({
}

// If this is a transaction thread associated with a report that only has one transaction, omit it
if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1')) {
if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1', parentReportAction)) {
return false;
}

Expand Down Expand Up @@ -5513,8 +5514,6 @@ function shouldReportBeInOptionList({
return false;
}

const parentReportAction = ReportActionsUtils.getParentReportAction(report);

// Hide chat threads where the parent message is pending removal
if (
!isEmptyObject(parentReportAction) &&
Expand Down
5 changes: 4 additions & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@ function getOrderedReportIDs(
return;
}
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {};
const parentReportAction = report.parentReportID && report.parentReportActionID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ReportActionsUtils.getParentReportAction here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's deprecated

? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.find((reportAction) => reportAction.reportActionID === report.parentReportActionID)
: undefined;
const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, betas ?? [], transactionViolations);
const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const isFocused = report.reportID === currentReportId;
const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {};
const hasErrorsOtherThanFailedReceipt =
doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== Localize.translateLocal('iou.error.genericSmartscanFailureMessage'));
if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0')) {
if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0', parentReportAction as ReportAction)) {
return;
}
if (hasErrorsOtherThanFailedReceipt) {
Expand Down
Loading