Skip to content

Commit 767f276

Browse files
MelvinBotdukenv0307
andcommitted
Deduplicate parentReport identity check into isParentReportDifferent boolean
Co-authored-by: dukenv0307 <dukenv0307@users.noreply.github.com>
1 parent 95ba3a2 commit 767f276

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/libs/actions/Report/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5500,7 +5500,8 @@ function resolveActionableMentionWhisper(
55005500
// the parent report's participants so the members list the user is viewing updates immediately.
55015501
// When parentReport is the same as the current report (e.g. viewing a transaction thread directly),
55025502
// fall back to the report's parentReportID to find the actual ancestor (IOU/expense/invoice report).
5503-
let parentInviteData = isInviteResolution && parentReport?.reportID && parentReport.reportID !== reportID ? buildParticipantsInviteData(parentReport, inviteeAccountIDs) : undefined;
5503+
const isParentReportDifferent = !!parentReport?.reportID && parentReport.reportID !== reportID;
5504+
let parentInviteData = isInviteResolution && isParentReportDifferent ? buildParticipantsInviteData(parentReport, inviteeAccountIDs) : undefined;
55045505
if (!parentInviteData && isInviteResolution && report?.parentReportID && report.parentReportID !== reportID) {
55055506
const ancestorReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`];
55065507
if (ancestorReport && (isMoneyRequestReport(ancestorReport) || isInvoiceReport(ancestorReport))) {
@@ -5509,7 +5510,7 @@ function resolveActionableMentionWhisper(
55095510
}
55105511
let parentReportIDForUpdate: string | undefined;
55115512
if (parentInviteData) {
5512-
parentReportIDForUpdate = parentReport?.reportID && parentReport.reportID !== reportID ? parentReport.reportID : report?.parentReportID;
5513+
parentReportIDForUpdate = isParentReportDifferent ? parentReport.reportID : report?.parentReportID;
55135514
}
55145515
const parentParticipantsOptimisticData = parentInviteData?.optimistic;
55155516
const parentParticipantsFailureData = parentInviteData?.failure;

0 commit comments

Comments
 (0)