From c535d03c84322eaaf64f809cb49f6f3eb8de3ce6 Mon Sep 17 00:00:00 2001 From: Pavlo Tsimura Date: Thu, 21 Sep 2023 08:35:55 +0200 Subject: [PATCH 1/2] Handle the green dot indicator for canceled tasks --- src/components/LHNOptionsList/OptionRowLHN.js | 4 ++-- src/components/LHNOptionsList/OptionRowLHNData.js | 2 +- src/libs/ReportUtils.js | 12 ++++++++++-- src/libs/SidebarUtils.js | 6 +++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index f5a293701454..da1eaad2f0c2 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -104,8 +104,8 @@ function OptionRowLHN(props) { const shouldShowGreenDotIndicator = !hasBrickError && (optionItem.isUnreadWithMention || - ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem) || - (optionItem.isTaskReport && optionItem.isTaskAssignee && !optionItem.isCompletedTaskReport && !optionItem.isArchivedRoom)); + optionItem.isWaitingForTaskCompleteFromAssignee || + ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem)); /** * Show the ReportActionContextMenu modal popover. diff --git a/src/components/LHNOptionsList/OptionRowLHNData.js b/src/components/LHNOptionsList/OptionRowLHNData.js index 2c51d6332946..345ba288c42d 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.js +++ b/src/components/LHNOptionsList/OptionRowLHNData.js @@ -106,7 +106,7 @@ function OptionRowLHNData({ const optionItem = useMemo(() => { // Note: ideally we'd have this as a dependent selector in onyx! - const item = SidebarUtils.getOptionData(fullReport, reportActions, personalDetails, preferredLocale, policy); + const item = SidebarUtils.getOptionData(fullReport, reportActions, personalDetails, preferredLocale, policy, parentReportAction); if (deepEqual(item, optionItemRef.current)) { return optionItemRef.current; } diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index edf646d0266b..384a2037fbe9 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1215,8 +1215,15 @@ function isWaitingForIOUActionFromCurrentUser(report) { return false; } -function isWaitingForTaskCompleteFromAssignee(report) { - return isTaskReport(report) && isReportManager(report) && isOpenTaskReport(report); +/** + * Checks if a report is an open task report assigned to current user. + * + * @param {Object} report + * @param {Object} parentReportAction - The parent report action of the report (Used to check if the task has been canceled) + * @returns {Boolean} + */ +function isWaitingForTaskCompleteFromAssignee(report, parentReportAction = {}) { + return isTaskReport(report) && isReportManager(report) && isOpenTaskReport(report, parentReportAction); } /** @@ -3701,4 +3708,5 @@ export { getReportPreviewDisplayTransactions, getTransactionsWithReceipts, hasMissingSmartscanFields, + isWaitingForTaskCompleteFromAssignee, }; diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index f645697690e6..0ea632aa7d63 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -210,9 +210,10 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p * @param {Object} personalDetails * @param {String} preferredLocale * @param {Object} [policy] + * @param {Object} parentReportAction * @returns {Object} */ -function getOptionData(report, reportActions, personalDetails, preferredLocale, policy) { +function getOptionData(report, reportActions, personalDetails, preferredLocale, policy, parentReportAction) { // When a user signs out, Onyx is cleared. Due to the lazy rendering with a virtual list, it's possible for // this method to be called after the Onyx data has been cleared out. In that case, it's fine to do // a null check here and return early. @@ -266,8 +267,7 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale, result.isChatRoom = ReportUtils.isChatRoom(report); result.isTaskReport = ReportUtils.isTaskReport(report); if (result.isTaskReport) { - result.isCompletedTaskReport = ReportUtils.isCompletedTaskReport(report); - result.isTaskAssignee = ReportUtils.isReportManager(report); + result.isWaitingForTaskCompleteFromAssignee = ReportUtils.isWaitingForTaskCompleteFromAssignee(report, parentReportAction); } result.isArchivedRoom = ReportUtils.isArchivedRoom(report); result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); From 847ba127b829df6770a6b2b2f23f179e044aff0c Mon Sep 17 00:00:00 2001 From: Pavlo Tsimura Date: Thu, 21 Sep 2023 08:48:47 +0200 Subject: [PATCH 2/2] Formatting --- src/components/LHNOptionsList/OptionRowLHN.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index da1eaad2f0c2..91b582221171 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -102,10 +102,7 @@ function OptionRowLHN(props) { const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; const defaultSubscriptSize = optionItem.isExpenseRequest ? CONST.AVATAR_SIZE.SMALL_NORMAL : CONST.AVATAR_SIZE.DEFAULT; const shouldShowGreenDotIndicator = - !hasBrickError && - (optionItem.isUnreadWithMention || - optionItem.isWaitingForTaskCompleteFromAssignee || - ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem)); + !hasBrickError && (optionItem.isUnreadWithMention || optionItem.isWaitingForTaskCompleteFromAssignee || ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem)); /** * Show the ReportActionContextMenu modal popover.