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 @@ -1472,10 +1472,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 @@ -5383,6 +5383,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 @@ -5414,7 +5415,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 @@ -5483,8 +5484,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
6 changes: 5 additions & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ function getOrderedReportIDs(
return;
}
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {};
const parentReportAction =
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const parentReportAction =
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it's basically the same as deprecated getParentReportAction which I guess gonna be deprecated in the future, but I updated it to not block the merge.

report.parentReportID && report.parentReportActionID
? 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