Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide task from LHN when not open #48534

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,15 @@ function editTask(report: OnyxTypes.Report, {title, description}: OnyxTypes.Task
Report.notifyNewAction(report.reportID, currentUserAccountID);
}

function editTaskAssignee(report: OnyxTypes.Report, ownerAccountID: number, assigneeEmail: string, assigneeAccountID: number | null = 0, assigneeChatReport?: OnyxEntry<OnyxTypes.Report>) {
function editTaskAssignee(report: OnyxTypes.Report, sessionAccountID: number, assigneeEmail: string, assigneeAccountID: number | null = 0, assigneeChatReport?: OnyxEntry<OnyxTypes.Report>) {
// Create the EditedReportAction on the task
const editTaskReportAction = ReportUtils.buildOptimisticChangedTaskAssigneeReportAction(assigneeAccountID ?? 0);
const reportName = report.reportName?.trim();

let assigneeChatReportOnyxData;
const assigneeChatReportID = assigneeChatReport ? assigneeChatReport.reportID : '-1';
const parentReport = getParentReport(report);
const taskOwnerAccountID = getTaskOwnerAccountID(report);
daledah marked this conversation as resolved.
Show resolved Hide resolved
const optimisticReport: OptimisticReport = {
reportName,
managerID: assigneeAccountID ?? report.managerID,
Expand All @@ -583,9 +585,10 @@ function editTaskAssignee(report: OnyxTypes.Report, ownerAccountID: number, assi
},
participants: {
[currentUserAccountID]: {
notificationPreference: [assigneeAccountID, ownerAccountID].includes(currentUserAccountID)
? CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS
: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
notificationPreference:
[assigneeAccountID, taskOwnerAccountID].includes(currentUserAccountID) && !parentReport
? CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS
: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
};
Expand Down Expand Up @@ -631,7 +634,6 @@ function editTaskAssignee(report: OnyxTypes.Report, ownerAccountID: number, assi
];

if (currentUserAccountID === assigneeAccountID) {
const parentReport = getParentReport(report);
if (!isEmptyObject(parentReport)) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -648,7 +650,6 @@ function editTaskAssignee(report: OnyxTypes.Report, ownerAccountID: number, assi

if (report.managerID === currentUserAccountID) {
const hasOutstandingChildTask = getOutstandingChildTask(report);
const parentReport = getParentReport(report);
if (!isEmptyObject(parentReport)) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -665,7 +666,7 @@ function editTaskAssignee(report: OnyxTypes.Report, ownerAccountID: number, assi

// If we make a change to the assignee, we want to add a comment to the assignee's chat
// Check if the assignee actually changed
if (assigneeAccountID && assigneeAccountID !== report.managerID && assigneeAccountID !== ownerAccountID && assigneeChatReport) {
if (assigneeAccountID && assigneeAccountID !== report.managerID && assigneeAccountID !== sessionAccountID && assigneeChatReport) {
optimisticReport.participants = {
...(optimisticReport.participants ?? {}),
[assigneeAccountID]: {
Expand Down
Loading