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

[$500] Web - Tasks - Assignee can mark task as completed after task has been #34172

Closed
1 of 6 tasks
kbecciv opened this issue Jan 9, 2024 · 13 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@kbecciv
Copy link

kbecciv commented Jan 9, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.23-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Issue found when executing PR #33656

Action Performed:

  1. Sign into account A and assign a task to account B
  2. Sign into account B and open the assigned task
  3. Sign back into account A and re assign the task to account C
  4. Sign into account B and open the assigned task and observe the assignee has changed
  5. Click the task as completed from account B

Expected Result:

Once the task is re assigned to account C account B should not be able to complete the task

Actual Result:

Even if the task is re assigned to account C, account B is still able to mark the task as completed

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6336939_1704821571346.assigneeChange.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011401c8786c4cfbb8
  • Upwork Job ID: 1744785613189410816
  • Last Price Increase: 2024-01-09
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 9, 2024
@melvin-bot melvin-bot bot changed the title Web - Tasks - Assignee can mark task as completed after task has been [$500] Web - Tasks - Assignee can mark task as completed after task has been Jan 9, 2024
Copy link

melvin-bot bot commented Jan 9, 2024

Job added to Upwork: https://www.upwork.com/jobs/~011401c8786c4cfbb8

Copy link

melvin-bot bot commented Jan 9, 2024

Triggered auto assignment to @CortneyOfstad (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 9, 2024
Copy link

melvin-bot bot commented Jan 9, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (External)

@s-alves10
Copy link
Contributor

s-alves10 commented Jan 9, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

An account can modify task when he isn't the assignee or the creator

What is the root cause of that problem?

We check the modifiability in the canModifyTask function
Please check the below code

if (sessionAccountID === getTaskOwnerAccountID(taskReport) || sessionAccountID === getTaskAssigneeAccountID(taskReport)) {
return true;
}

As you can see, we return true if the current user is the owner or the assignee. Even when the user isn't the owner and isn't the assignee, we allow the modification when the parent report is allowed to comment

return ReportUtils.isAllowedToComment(parentReport);

This is the root cause

What changes do you think we should make in order to solve the problem?

The main idea is that we should return false if the user isn't the creator nor the assignee instead of returning true if the user is the creator or the assignee

Updating

if (sessionAccountID === getTaskOwnerAccountID(taskReport) || sessionAccountID === getTaskAssigneeAccountID(taskReport)) {
return true;
}

to

    if (sessionAccountID !== getTaskOwnerAccountID(taskReport) && sessionAccountID !== getTaskAssigneeAccountID(taskReport)) {
        return false;
    }

would solve the issue

Note: If we need to allow modification of the task for policy admins in the workspace chat or chat room, we would need to add those conditions with &&

What alternative solutions did you explore? (Optional)

@Santhosh-Sellavel
Copy link
Collaborator

Proposal looks good to need ensure whether this issues comes from any recent PR which is under regression period

@paultsimura
Copy link
Contributor

paultsimura commented Jan 9, 2024

Proposal looks good

This change will break the ability for public room admins to modify tasks

@s-alves10
Copy link
Contributor

This change will break the ability for public room admins to modify tasks

Yeah, we need to add those conditions as well if admins should be able to modify tasks.

@paultsimura
Copy link
Contributor

paultsimura commented Jan 9, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

What is the root cause of that problem?

The root cause is that when checking for the user's ability to modify the task, neither of early return conditions are met, and we get all the way to the last return, which checks if the user can comment on the parent chat (their 1:1 chat).

/**
* Check if you're allowed to modify the task - anyone that has write access to the report can modify the task
* @param {Object} taskReport
* @param {Number} sessionAccountID
* @param {String} policyRole
*
* @returns {Boolean}
*/
function canModifyTask(taskReport, sessionAccountID, policyRole = '') {
if (ReportUtils.isCanceledTaskReport(taskReport)) {
return false;
}
if (sessionAccountID === getTaskOwnerAccountID(taskReport) || sessionAccountID === getTaskAssigneeAccountID(taskReport)) {
return true;
}
const parentReport = ReportUtils.getParentReport(taskReport);
if (policyRole && (ReportUtils.isChatRoom(parentReport) || ReportUtils.isPolicyExpenseChat(parentReport)) && policyRole !== CONST.POLICY.ROLE.ADMIN) {
return false;
}
// If you don't have access to the task report (maybe haven't opened it yet), check if you can access the parent report
// - If the parent report is an #admins only room
// - If you are a policy admin
return ReportUtils.isAllowedToComment(parentReport);
}

What changes do you think we should make in order to solve the problem?

In this function, we should early return false if the parent report is a chat report:

    const parentReport = ReportUtils.getParentReport(taskReport);
+    if (ReportUtils.isChatReport(parentReport)) {
+        return false;
+    }

This is safe to add because:

  1. We have verified earlier that the current user is neither the task owner nor the task assignee:

    if (sessionAccountID === getTaskOwnerAccountID(taskReport) || sessionAccountID === getTaskAssigneeAccountID(taskReport)) {
    return true;
    }

  2. This is not a room or workspace, but a chat, so the user should have no right to modify this task if they are neither the owner nor an assignee of this task

What alternative solutions did you explore? (Optional)

@dukenv0307
Copy link
Contributor

Seem like it's expected cc @thienlnam

@thienlnam
Copy link
Contributor

Anyone can modify the task if you can access it - this is intended

@thienlnam
Copy link
Contributor

@kbecciv Can you please post the TR that created this issue? I believe we fixed a bunch but there might be more that we are missing

@kbecciv
Copy link
Author

kbecciv commented Jan 10, 2024

This issue discovered when executing PR #33656 @thienlnam

@thienlnam
Copy link
Contributor

Ah yeah - the expected behavior is that anyone that can view the task can modify the task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

7 participants