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

[$250] Invoices - Workspace settings can be opened from "workspace" link when workspace is deleted #49093

Open
6 tasks done
IuliiaHerets opened this issue Sep 12, 2024 · 35 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Sep 12, 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: 9.0.33-1
Reproducible in staging?: Y
Reproducible in production?: N/A - new feature, doesn't exist in prod
Issue was found when executing this PR: #48275
Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

Precondition:

  • User B has no workspace.
  1. Go to staging.new.expensify.com
  2. {User A] Send an invoice to User B.
  3. [User B] Pay the invoice using Pay as a business option.
  4. [User B] Delete the workspace.
  5. {User B] Go to invoice chat.
  6. [User B] Click on the "workspace" link in Expensify message.

Expected Result:

The link should lead to not here page because workspace is deleted.

Actual Result:

The link can open workspace settings page and Members tab leads to not here page.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6601039_1726148441534.20240912_213050.1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021834598579747458653
  • Upwork Job ID: 1834598579747458653
  • Last Price Increase: 2024-09-13
  • Automatic offers:
    • ishpaul777 | Contributor | 104008088
    • gijoe0295 | Contributor | 104027162
Issue OwnerCurrent Issue Owner: @ntdiary
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. DeployBlocker Indicates it should block deploying the API labels Sep 12, 2024
Copy link

melvin-bot bot commented Sep 12, 2024

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added the Daily KSv2 label Sep 12, 2024
@IuliiaHerets
Copy link
Author

We think that this bug might be related to #vip-bills

@iwiznia iwiznia removed the DeployBlocker Indicates it should block deploying the API label Sep 12, 2024
@iwiznia
Copy link
Contributor

iwiznia commented Sep 12, 2024

@m-natarajan m-natarajan added the DeployBlockerCash This issue or pull request should block deployment label Sep 12, 2024
Copy link

melvin-bot bot commented Sep 12, 2024

Triggered auto assignment to @srikarparsi (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@luacmartins
Copy link
Contributor

@IuliiaHerets I think the uploaded video is incorrect. Can you please check?

@IuliiaHerets
Copy link
Author

@luacmartins fixed, sorry for this

@luacmartins
Copy link
Contributor

No problem. Thank you!

@luacmartins
Copy link
Contributor

This is also reproducible in prod if we just copy/paste the workspace link

@luacmartins luacmartins added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Sep 12, 2024
@rlinoz
Copy link
Contributor

rlinoz commented Sep 12, 2024

Just by having the workspace link in any chat the problem also happens in prod:

Screen.Recording.2024-09-12.at.14.46.18.mov

@IuliiaHerets
Copy link
Author

We can't pay the invoice using Pay as a business in prod, so I marked it as N/A - can't check on prod

@gijoe0295
Copy link
Contributor

gijoe0295 commented Sep 12, 2024

Edited by proposal-police: This proposal was edited at 2023-10-06T15:00:00Z.

Proposal

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

The link can open workspace settings page and Members tab leads to not here page.

What is the root cause of that problem?

After deleting the workspace, we still retain some workspace information to show the invoice report's avatars and name:

Screenshot 2024-09-13 at 01 27 59

These information is returned by OpenReport:

Screenshot 2024-09-13 at 01 28 52

The not found page condition here simply checks for empty/delete-pending policy:

return (
(!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin) ||
(PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy))
);

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

  1. We can add shouldShowPolicy to the shouldShowNotFoundPage above to filter these workspaces and prevent them from being accessed by URL:

App/src/libs/PolicyUtils.ts

Lines 180 to 187 in 7748eff

function shouldShowPolicy(policy: OnyxEntry<Policy>, isOffline: boolean, currentUserLogin: string | undefined): boolean {
return (
!!policy &&
(policy?.type !== CONST.POLICY.TYPE.PERSONAL || !!policy?.isJoinRequestPending) &&
(isOffline || policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || Object.keys(policy.errors ?? {}).length > 0) &&
!!getPolicyRole(policy, currentUserLogin)
);
}

This condition is also used in WorkspacesListPage to filter viewable workspace. This solution ensures if a workspace did not appear in the workspaces list, it should not be accessible via direct URL.

.filter((policy): policy is PolicyType => PolicyUtils.shouldShowPolicy(policy, !!isOffline))

  1. We also need to add the above filter to WorkspaceInitialPage and WorkspaceProfilePage:

const shouldShowNotFoundPage =

shouldShowNotFoundPage={policy === undefined}

  1. And modify the not found subtitle in those pages as well since they are assuming that only empty policies are deleted:

subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}

subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}

@joekaufmanexpensify joekaufmanexpensify added the External Added to denote the issue can be worked on by a contributor label Sep 13, 2024
@melvin-bot melvin-bot bot changed the title Invoices - Workspace settings can be opened from "workspace" link when workspace is deleted [$250] Invoices - Workspace settings can be opened from "workspace" link when workspace is deleted Sep 13, 2024
Copy link

melvin-bot bot commented Sep 13, 2024

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

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

melvin-bot bot commented Sep 16, 2024

@ntdiary, @srikarparsi, @joekaufmanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@joekaufmanexpensify
Copy link
Contributor

@ntdiary can you review proposals here?

@ntdiary
Copy link
Contributor

ntdiary commented Sep 17, 2024

@ntdiary can you review proposals here?

Ah, @joekaufmanexpensify, sorry, under review. I missed this issue. 😅

@melvin-bot melvin-bot bot removed the Overdue label Sep 17, 2024
@allgandalf
Copy link
Contributor

Taking over this issue (slack), can you please assign me here @joekaufmanexpensify @srikarparsi

@joekaufmanexpensify
Copy link
Contributor

We ended up rolling the dice for this one since there was a lot of interest, and @ishpaul777 was selected, so going with them!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 17, 2024
Copy link

melvin-bot bot commented Sep 17, 2024

📣 @ishpaul777 🎉 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 📖

@joekaufmanexpensify joekaufmanexpensify added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 17, 2024
@joekaufmanexpensify
Copy link
Contributor

Pending @ishpaul777 review of proposals

@ishpaul777
Copy link
Contributor

Looking 👀

@ishpaul777
Copy link
Contributor

@nkdengineer I dont understand the usage for prevShouldShowPolicy in your proposal could you clarify the usage please ?

@nkdengineer
Copy link
Contributor

PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)

@ishpaul777 Here is the old condition and we should replace it with shouldShowPolicy function. That is why we have prevShouldShowPolicy variable. I create a new variable because we need to use shouldShowPolicy to display the correct subtitle.

subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}

@ishpaul777
Copy link
Contributor

Thanks for clarifying @nkdengineer. 👍


I dont think there are any major difference between @nkdengineer solution and @gijoe0295's solution, since @gijoe0295 Proposed this first lets assign them

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 18, 2024

Current assignee @srikarparsi is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 18, 2024
Copy link

melvin-bot bot commented Sep 18, 2024

📣 @gijoe0295 🎉 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 📖

@joekaufmanexpensify
Copy link
Contributor

@gijoe0295 is there an ETA for PR here?

@gijoe0295
Copy link
Contributor

Will complete in 5 hours.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 20, 2024
@joekaufmanexpensify
Copy link
Contributor

PR in review

@joekaufmanexpensify
Copy link
Contributor

PR still in review

@ishpaul777
Copy link
Contributor

Still in review, found a bug that is taking sometime to fix, @gijoe0295 is still looking into it

@joekaufmanexpensify
Copy link
Contributor

Sounds good!

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. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Status: No status
Development

No branches or pull requests