Skip to content

Commit

Permalink
Merge pull request #27915 from paultsimura/fix/27805-deleted-task-gre…
Browse files Browse the repository at this point in the history
…en-dot

fix: Web - green dot appears even if task is deleted
  • Loading branch information
tgolen authored Sep 25, 2023
2 parents f5409e7 + 847ba12 commit 4348c30
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem) ||
(optionItem.isTaskReport && optionItem.isTaskAssignee && !optionItem.isCompletedTaskReport && !optionItem.isArchivedRoom));
!hasBrickError && (optionItem.isUnreadWithMention || optionItem.isWaitingForTaskCompleteFromAssignee || ReportUtils.isWaitingForIOUActionFromCurrentUser(optionItem));

/**
* Show the ReportActionContextMenu modal popover.
Expand Down
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHNData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1238,8 +1238,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);
}

/**
Expand Down Expand Up @@ -3748,4 +3755,5 @@ export {
getReportPreviewDisplayTransactions,
getTransactionsWithReceipts,
hasMissingSmartscanFields,
isWaitingForTaskCompleteFromAssignee,
};
6 changes: 3 additions & 3 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,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.
Expand Down Expand Up @@ -277,8 +278,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);
Expand Down

0 comments on commit 4348c30

Please sign in to comment.