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

[HOLD for payment 2024-01-11] [$500] Task - Task assignee list opens with deep link when user has no access to edit task #33296

Closed
5 of 6 tasks
kbecciv opened this issue Dec 19, 2023 · 27 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Dec 19, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.14.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:

Action Performed:

Precondition:

  • User is a member of the #announce workspace room in which a task is created and assigned to other user.
  1. Log in as member of the workspace.
  2. Go to #announce room.
  3. Click on the task.
  4. Add /assignee to the end of the link.
  5. Select a different assignee.

Expected Result:

Not here page opens.

Actual Result:

Task assignee list opens.

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

Bug6319789_1702998210569.20231219_191222.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c0cdfb5367dcebe3
  • Upwork Job ID: 1737132419534086144
  • Last Price Increase: 2023-12-19
  • Automatic offers:
    • dukenv0307 | Contributor | 28067679
    • c3024 | Contributor | 28072736
@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 Dec 19, 2023
Copy link

melvin-bot bot commented Dec 19, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01c0cdfb5367dcebe3

@melvin-bot melvin-bot bot changed the title Task - Task assignee list opens with deep link when user has no access to edit task [$500] Task - Task assignee list opens with deep link when user has no access to edit task Dec 19, 2023
Copy link

melvin-bot bot commented Dec 19, 2023

Triggered auto assignment to @garrettmknight (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 Dec 19, 2023
Copy link

melvin-bot bot commented Dec 19, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

Copy link

melvin-bot bot commented Dec 19, 2023

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

@bernhardoj
Copy link
Contributor

bernhardoj commented Dec 19, 2023

Proposal

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

We can access task assignee page even though we don't have access to.

What is the root cause of that problem?

We already have a condition here to disable it if the user doesn't have the permission (canModifyTask).

const canModifyTask = Task.canModifyTask(report, props.currentUserPersonalDetails.accountID, lodashGet(props.rootParentReportPolicy, 'role', ''));
const isTaskNonEditable = ReportUtils.isTaskReport(report) && (!canModifyTask || !isOpen);

But the problem here is that the rootParentReportPolicy is always empty. If we look at how we get that data, we can see that it depends on report onyx data, but we never have the report data, we only subscribe to reports (the whole collection) data.

withOnyx({
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
},

rootParentReportPolicy: {
key: ({report}) => {
const rootParentReport = ReportUtils.getRootParentReport(report);
return `${ONYXKEYS.COLLECTION.POLICY}${rootParentReport ? rootParentReport.policyID : '0'}`;
},
selector: (policy) => _.pick(policy, ['role']),
},

So, report is always empty.

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

Add a new Onyx subscription to get the current report, just like we do in other places. (put it before rootParentReportPolicy)

report: {
    key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID')}`,
},

With this change, we can now remove this code and replace all of its usage with the report from the props.

const report = useMemo(() => {
if (!props.route.params || !props.route.params.reportID) {
return null;
}
return props.reports[`${ONYXKEYS.COLLECTION.REPORT}${props.route.params.reportID}`];
}, [props.reports, props.route.params]);

@dukenv0307
Copy link
Contributor

dukenv0307 commented Dec 19, 2023

Proposal

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

Task assignee list opens.

What is the root cause of that problem?

In here, we're relying on the report in order to get the rootParentReportPolicy, however, on that page we're not getting the report, we get the full reports collection as can be seen here. This is because this selector modal is used in both create and edit case, when used in edit case, it has the reportID, when used in create case, it does not.

This leads to the report here to always be empty, the rootParentReportPolicy will be empty and the canModifyTask here is true, which is incorrect. This causes the user to be able to access that page.

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

In here, we should use the reports instead, and get the report via the route.params.reportID similar to here to use to get the rootParentReportPolicy.

I believe it's intentional to not connect to the report key in Onyx since the data is already available in reports and we don't want extra (double) rerendering of the assignee page due to that redundant key.

Optionally, since both this change and this existing code are getting the report via reportID and reports, we can modify this util to accept a second reports param (which defaults to the allReports) and use it in both places for DRY.

What alternative solutions did you explore? (Optional)

NA

@yh-0218
Copy link
Contributor

yh-0218 commented Dec 19, 2023

Proposal

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

Task - Task assignee list opens with deep link when user has no access to edit task

What is the root cause of that problem?

We did get report as props of parent on TaskAssigneeSelectorModal
so props.rootParentReportPolicy is empty on TaskAssigneeSelectorModal

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

We can passed from reportID from param.

rootParentReportPolicy: {
            key: ({route}) => {
                const report = ReportUtils.getReport(route.params.reportID)
                const rootParentReport = ReportUtils.getRootParentReport(report);
                return `${ONYXKEYS.COLLECTION.POLICY}${rootParentReport ? rootParentReport.policyID : '0'}`;
            },
            selector: (policy) => _.pick(policy, ['role']),
},

What alternative solutions did you explore? (Optional)

@narefyev91
Copy link
Contributor

Proposal from @dukenv0307 looks good to me #33296 (comment)
In case that we already have all reports at this page - no needs to have additional subscription to specific report from onyx
Let's just work with reports and reportId
🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Dec 20, 2023

Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@bernhardoj
Copy link
Contributor

@narefyev91 I think having a different way to get the report object (to optimize it) is something that can be discussed on the PR stage itself.

@dukenv0307
Copy link
Contributor

@narefyev91 I think having a different way to get the report object (to optimize it) is something that can be discussed on the PR stage itself.

I think this issue is straightforward so an optimized solution that doesn't degrade performance should be preferred before we get to the PR, where we might or might not realize the issue and could have the bad code merged.

@melvin-bot melvin-bot bot added the Overdue label Dec 22, 2023
@lakchote
Copy link
Contributor

@dukenv0307's proposal LGTM 👍

@melvin-bot melvin-bot bot removed the Overdue label Dec 22, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 22, 2023
Copy link

melvin-bot bot commented Dec 22, 2023

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@c3024
Copy link
Contributor

c3024 commented Dec 22, 2023

Taking this over.

@melvin-bot melvin-bot bot added the Weekly KSv2 label Dec 25, 2023
@dukenv0307
Copy link
Contributor

@narefyev91 this PR is ready for review.

@garrettmknight garrettmknight assigned c3024 and unassigned narefyev91 Dec 29, 2023
Copy link

melvin-bot bot commented Dec 29, 2023

📣 @c3024 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@garrettmknight
Copy link
Contributor

@c3024 you're up!

@c3024
Copy link
Contributor

c3024 commented Dec 29, 2023

PR review done. Awaiting final approval for merge by @lakchote

Copy link

melvin-bot bot commented Dec 29, 2023

Triggered auto assignment to @robertjchen (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@garrettmknight
Copy link
Contributor

Reassigning since @lakchote is out for parental leave.

@robertjchen
Copy link
Contributor

Merged!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 4, 2024
@melvin-bot melvin-bot bot changed the title [$500] Task - Task assignee list opens with deep link when user has no access to edit task [HOLD for payment 2024-01-11] [$500] Task - Task assignee list opens with deep link when user has no access to edit task Jan 4, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jan 4, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.21-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-01-11. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jan 4, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@c3024] The PR that introduced the bug has been identified. Link to the PR:
  • [@c3024] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@c3024] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@c3024] Determine if we should create a regression test for this bug.
  • [@c3024] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@garrettmknight] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@c3024
Copy link
Contributor

c3024 commented Jan 12, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@c3024] The PR that introduced the bug has been identified. Link to the PR: Fix/31863: Don't allow member to edit task in room #32165
  • [@c3024] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: de9e6d4#r136920736
  • [@c3024] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: NA
  • [@c3024] Determine if we should create a regression test for this bug. Yes
  • [@c3024] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

@c3024
Copy link
Contributor

c3024 commented Jan 12, 2024

Regression test proposal

  1. In the #announce room of a workspace W, create a task as User A and assign it to User B
  2. Log in as User C (who is also a member of the workspace W)
  3. Go to #announce room of the workspace W
  4. Click on the task created at step 1
  5. Add /assignee to the end of the URL and visit the URL
  6. Verify that "Not here" page is displayed.

👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Jan 14, 2024
@garrettmknight
Copy link
Contributor

Everybody's paid and the QA issue is up. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants