Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.34k stars 2.77k forks source link

[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 kbecciv closed 8 months ago

kbecciv commented 9 months ago

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.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:

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?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/93399543/032635f8-42b0-445b-9c4f-bb89e19327b9

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
melvin-bot[bot] commented 9 months ago

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

melvin-bot[bot] commented 9 months ago

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

melvin-bot[bot] commented 9 months ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 9 months ago

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

bernhardoj commented 9 months ago

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). https://github.com/Expensify/App/blob/b3ecf327c585ca323a628405f4ffc70877c601a0/src/pages/tasks/TaskAssigneeSelectorModal.js#L208-L209

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. https://github.com/Expensify/App/blob/b3ecf327c585ca323a628405f4ffc70877c601a0/src/pages/tasks/TaskAssigneeSelectorModal.js#L249-L252 https://github.com/Expensify/App/blob/b3ecf327c585ca323a628405f4ffc70877c601a0/src/pages/tasks/TaskAssigneeSelectorModal.js#L262-L268

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. https://github.com/Expensify/App/blob/b3ecf327c585ca323a628405f4ffc70877c601a0/src/pages/tasks/TaskAssigneeSelectorModal.js#L129-L134

dukenv0307 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

Proposal from @dukenv0307 looks good to me https://github.com/Expensify/App/issues/33296#issuecomment-1863051968 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

melvin-bot[bot] commented 9 months ago

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

bernhardoj commented 9 months ago

@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 commented 9 months ago

@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.

lakchote commented 9 months ago

@dukenv0307's proposal LGTM πŸ‘

melvin-bot[bot] commented 9 months ago

πŸ“£ @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 commented 9 months ago

Taking this over.

dukenv0307 commented 8 months ago

@narefyev91 this PR is ready for review.

melvin-bot[bot] commented 8 months ago

πŸ“£ @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 commented 8 months ago

@c3024 you're up!

c3024 commented 8 months ago

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

melvin-bot[bot] commented 8 months ago

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

garrettmknight commented 8 months ago

Reassigning since @lakchote is out for parental leave.

robertjchen commented 8 months ago

Merged!

melvin-bot[bot] commented 8 months ago

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

melvin-bot[bot] commented 8 months ago

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

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

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.

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

melvin-bot[bot] commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 πŸ‘Ž

garrettmknight commented 8 months ago

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