From 4d71acc489810fb57745b706d68e1b9499b8a9db Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Wed, 28 Aug 2024 15:22:13 -0600 Subject: [PATCH 1/3] Show GBR if manager w/out parent access on procesing report --- src/libs/ReportUtils.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f8f85beff4ad..42b3d26df53c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2533,8 +2533,14 @@ function isWaitingForAssigneeToCompleteTask(report: OnyxEntry, parentRep return true; } - if (isOpenTaskReport(report, parentReportAction) && !report?.hasParentAccess && isReportManager(report)) { - return true; + if (!report?.hasParentAccess && isReportManager(report)) { + if (isOpenTaskReport(report, parentReportAction)) { + return true; + } + + if (isProcessingReport(report) && isExpenseReport(report)) { + return true; + } } return false; @@ -5906,6 +5912,9 @@ function shouldReportBeInOptionList({ login?: string; includeDomainEmail?: boolean; }) { + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE', report); + } const isInDefaultMode = !isInFocusMode; // Exclude reports that have no data because there wouldn't be anything to show in the option item. // This can happen if data is currently loading from the server or a report is in various stages of being created. @@ -5932,23 +5941,38 @@ function shouldReportBeInOptionList({ !isSystemChat(report) && !isGroupChat(report)) ) { + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE 1'); + } return false; } if (report?.participants?.[CONST.ACCOUNT_ID.NOTIFICATIONS] && (!currentUserAccountID || !AccountUtils.isAccountIDOddNumber(currentUserAccountID))) { + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE 2'); + } return false; } if (!canAccessReport(report, policies, betas)) { + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE 3'); + } return false; } // If this is a transaction thread associated with a report that only has one transaction, omit it if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1', parentReportAction)) { + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE 4'); + } return false; } if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) { + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE 5'); + } return false; } @@ -5961,6 +5985,9 @@ function shouldReportBeInOptionList({ // Retrieve the draft comment for the report and convert it to a boolean const hasDraftComment = hasValidDraftComment(report.reportID); + if (report && report.reportID === '4638809485619813') { + console.log('[BEAMAN] HERE PLZ?'); + } // Include reports that are relevant to the user in any view mode. Criteria include having a draft or having a GBR showing. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing From 5fdb9bbc8a5f73cee438abac4ca24a6d124b0fef Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Wed, 28 Aug 2024 16:26:05 -0600 Subject: [PATCH 2/3] Remove console logs --- src/libs/ReportUtils.ts | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 42b3d26df53c..4380410f936b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5912,9 +5912,6 @@ function shouldReportBeInOptionList({ login?: string; includeDomainEmail?: boolean; }) { - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE', report); - } const isInDefaultMode = !isInFocusMode; // Exclude reports that have no data because there wouldn't be anything to show in the option item. // This can happen if data is currently loading from the server or a report is in various stages of being created. @@ -5941,38 +5938,23 @@ function shouldReportBeInOptionList({ !isSystemChat(report) && !isGroupChat(report)) ) { - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE 1'); - } return false; } if (report?.participants?.[CONST.ACCOUNT_ID.NOTIFICATIONS] && (!currentUserAccountID || !AccountUtils.isAccountIDOddNumber(currentUserAccountID))) { - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE 2'); - } return false; } if (!canAccessReport(report, policies, betas)) { - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE 3'); - } return false; } // If this is a transaction thread associated with a report that only has one transaction, omit it if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1', parentReportAction)) { - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE 4'); - } return false; } if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) { - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE 5'); - } return false; } @@ -5985,9 +5967,6 @@ function shouldReportBeInOptionList({ // Retrieve the draft comment for the report and convert it to a boolean const hasDraftComment = hasValidDraftComment(report.reportID); - if (report && report.reportID === '4638809485619813') { - console.log('[BEAMAN] HERE PLZ?'); - } // Include reports that are relevant to the user in any view mode. Criteria include having a draft or having a GBR showing. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing From 4395c982c0f47e134c14f69521fa17091f74e96d Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Aug 2024 09:10:57 -0600 Subject: [PATCH 3/3] Rename and reuse function --- src/libs/ReportUtils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4380410f936b..491fbdec07ab 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2524,11 +2524,12 @@ function getLastVisibleMessage(reportID: string | undefined, actionsToMerge: Rep } /** - * Checks if a report is an open task report assigned to current user. + * Checks if a report is waiting for the manager to complete an action. + * Example: the assignee of an open task report or the manager of a processing expense report. * * @param [parentReportAction] - The parent report action of the report (Used to check if the task has been canceled) */ -function isWaitingForAssigneeToCompleteTask(report: OnyxEntry, parentReportAction: OnyxEntry): boolean { +function isWaitingForAssigneeToCompleteAction(report: OnyxEntry, parentReportAction: OnyxEntry): boolean { if (report?.hasOutstandingChildTask) { return true; } @@ -2586,7 +2587,7 @@ function requiresAttentionFromCurrentUser(optionOrReport: OnyxEntry | Op return true; } - if (isWaitingForAssigneeToCompleteTask(optionOrReport, parentReportAction)) { + if (isWaitingForAssigneeToCompleteAction(optionOrReport, parentReportAction)) { return true; } @@ -7970,7 +7971,7 @@ export { isUserCreatedPolicyRoom, isValidReport, isValidReportIDFromPath, - isWaitingForAssigneeToCompleteTask, + isWaitingForAssigneeToCompleteAction, isInvoiceRoom, isInvoiceRoomWithID, isInvoiceReport,