Skip to content

Commit

Permalink
when getting the navigation subtitle, do not recursively go through p…
Browse files Browse the repository at this point in the history
…arents, but rather always use the immediate parent
  • Loading branch information
barros001 committed Feb 28, 2024
1 parent 4fcfbb0 commit 2abcf72
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2558,19 +2558,14 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
}

/**
* Recursively navigates through thread parents to get the root report and workspace name.
* The recursion stops when we find a non thread or money request report, whichever comes first.
* Get the report name and workspace name for a report based on the type of the report
*/
function getRootReportAndWorkspaceName(report: OnyxEntry<Report>): ReportAndWorkspaceName {
function getReportAndWorkspaceName(report: OnyxEntry<Report>): ReportAndWorkspaceName {
if (!report) {
return {
rootReportName: '',
};
}
if (isChildReport(report) && !isMoneyRequestReport(report) && !isTaskReport(report)) {
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
return getRootReportAndWorkspaceName(parentReport);
}

if (isIOURequest(report)) {
return {
Expand Down Expand Up @@ -2617,16 +2612,17 @@ function getChatRoomSubtitle(report: OnyxEntry<Report>): string | undefined {
* Gets the parent navigation subtitle for the report
*/
function getParentNavigationSubtitle(report: OnyxEntry<Report>): ParentNavigationSummaryParams {
if (isThread(report)) {
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
const {rootReportName, workspaceName} = getRootReportAndWorkspaceName(parentReport);
if (!rootReportName) {
return {};
}
if (!isThread(report)) {
return {};
}

return {rootReportName, workspaceName};
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
const {rootReportName, workspaceName} = getReportAndWorkspaceName(parentReport);
if (!rootReportName) {
return {};
}
return {};

return {rootReportName, workspaceName};
}

/**
Expand Down

0 comments on commit 2abcf72

Please sign in to comment.