Skip to content

Commit

Permalink
Merge pull request #20808 from Expensify/youssef_greenDot_uncompleted…
Browse files Browse the repository at this point in the history
…_tasks
  • Loading branch information
thienlnam authored Jun 15, 2023
2 parents c4ef02b + 286c623 commit d920d19
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ function OptionRowLHN(props) {
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;

const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
const shouldShowGreenDotIndicator = !hasBrickError && (optionItem.isUnreadWithMention || (optionItem.hasOutstandingIOU && !optionItem.isIOUReportOwner));
const shouldShowGreenDotIndicator =
!hasBrickError &&
(optionItem.isUnreadWithMention ||
(optionItem.hasOutstandingIOU && !optionItem.isIOUReportOwner) ||
(optionItem.isTaskReport && optionItem.isTaskAssignee && !optionItem.isTaskCompleted));

/**
* Show the ReportActionContextMenu modal popover.
Expand Down
5 changes: 2 additions & 3 deletions src/components/TaskHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {useEffect} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import reportPropTypes from '../pages/reportPropTypes';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import * as ReportUtils from '../libs/ReportUtils';
Expand Down Expand Up @@ -39,7 +38,7 @@ function TaskHeader(props) {
const assigneeName = ReportUtils.getDisplayNameForParticipant(props.report.managerID);
const assigneeAvatar = UserUtils.getAvatar(lodashGet(props.personalDetails, [props.report.managerID, 'avatar']), props.report.managerID);
const isOpen = props.report.stateNum === CONST.REPORT.STATE_NUM.OPEN && props.report.statusNum === CONST.REPORT.STATUS.OPEN;
const isCompleted = props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum === CONST.REPORT.STATUS.APPROVED;
const isCompleted = ReportUtils.isTaskCompleted(props.report);

useEffect(() => {
TaskUtils.setTaskReport(props.report);
Expand All @@ -60,7 +59,7 @@ function TaskHeader(props) {
>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween, styles.pv3]}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween]}>
{!_.isEmpty(props.report.managerID) && (
{props.report.managerID && props.report.managerID > 0 && (
<>
<Avatar
source={assigneeAvatar}
Expand Down
22 changes: 22 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@ function isTaskReport(report) {
return lodashGet(report, 'type') === CONST.REPORT.TYPE.TASK;
}

/**
* Checks if a task is completed
*
* @param {Object} report
* @returns {Boolean}
*/
function isTaskCompleted(report) {
return lodashGet(report, 'stateNum') === CONST.REPORT.STATE_NUM.SUBMITTED && lodashGet(report, 'statusNum') === CONST.REPORT.STATUS.APPROVED;
}

/**
* Checks if the current user is assigned to the task report
*
* @param {Object} report
* @returns {Boolean}
*/
function isTaskAssignee(report) {
return lodashGet(report, 'managerEmail') === currentUserEmail;
}

/**
* Checks if a report is an IOU or expense report.
*
Expand Down Expand Up @@ -2296,6 +2316,8 @@ export {
isExpenseReport,
isIOUReport,
isTaskReport,
isTaskCompleted,
isTaskAssignee,
isMoneyRequestReport,
chatIncludesChronos,
getNewMarkerReportActionID,
Expand Down
6 changes: 5 additions & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function getOrderedReportIDs(reportIDFromRoute) {
return;
}

if (ReportUtils.isTaskReport(report) && report.stateNum !== CONST.REPORT.STATE.OPEN && report.statusNum !== CONST.REPORT.STATUS.OPEN) {
if (ReportUtils.isTaskReport(report) && ReportUtils.isTaskCompleted(report)) {
archivedReports.push(report);
return;
}
Expand Down Expand Up @@ -266,6 +266,10 @@ function getOptionData(reportID) {
result.isThread = ReportUtils.isThread(report);
result.isChatRoom = ReportUtils.isChatRoom(report);
result.isTaskReport = ReportUtils.isTaskReport(report);
if (result.isTaskReport) {
result.isTaskCompleted = ReportUtils.isTaskCompleted(report);
result.isTaskAssignee = ReportUtils.isTaskAssignee(report);
}
result.isArchivedRoom = ReportUtils.isArchivedRoom(report);
result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
Expand Down
5 changes: 3 additions & 2 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ function editTaskAndNavigate(report, ownerEmail, ownerAccountID, {title, descrip
// If we make a change to the assignee, we want to add a comment to the assignee's chat
let optimisticAssigneeAddComment;
let assigneeChatReportID;
if (assigneeAccountID && assigneeAccountID !== report.managerID) {
if (assigneeAccountID && assigneeAccountID !== report.managerID && assigneeAccountID !== ownerAccountID) {
assigneeChatReportID = ReportUtils.getChatByParticipants([assigneeAccountID]).reportID;

if (assigneeChatReportID !== report.parentReportID.toString()) {
optimisticAssigneeAddComment = ReportUtils.buildOptimisticTaskCommentReportAction(
report.reportID,
Expand Down Expand Up @@ -493,7 +494,7 @@ function setAssigneeValue(assignee, assigneeAccountID, shareDestination, isCurre
}

// This is only needed for creation of a new task and so it should only be stored locally
Onyx.merge(ONYXKEYS.TASK, {assignee, newAssigneeAccountID});
Onyx.merge(ONYXKEYS.TASK, {assignee, assigneeAccountID: newAssigneeAccountID});
}

/**
Expand Down

0 comments on commit d920d19

Please # to comment.