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.49k stars 2.85k forks source link

[$250] Workspace list is opened when opening a WS share code without any access to it #51000

Open izarutskaya opened 6 days ago

izarutskaya commented 6 days 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: 9.0.50-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Found when validation PR https://github.com/Expensify/App/pull/50875 Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team

Action Performed:

Preconditions: Uninstall ND app. A Gmail user should be at it's own workspace share code page on web.

  1. Navigate to https://staging.new.expensify.com/
  2. Log in with a different, new Gmail user
  3. Open iOS "Camera" app
  4. Point the feed to the QR code
  5. Tap on the button to navigate to it

Expected Result:

I should be navigated to the "it's not here" page with an option to request access.

Actual Result:

Workspace list is opened when opening a WS share code without any access to it.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/b74078d2-2c9a-4791-ac8f-79a931caf945

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021847411075396403416
  • Upwork Job ID: 1847411075396403416
  • Last Price Increase: 2024-10-18
Issue OwnerCurrent Issue Owner: @sobitneupane
melvin-bot[bot] commented 6 days ago

Triggered auto assignment to @adelekennedy (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.

izarutskaya commented 6 days ago

We think this issue might be related to the #collect project.

bernhardoj commented 6 days ago

Proposal

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

WS list is opened when trying to open a WS shared link without any access.

What is the root cause of that problem?

The WS share link actually points to a WS join link (e.g., https://new.expensify.com/settings/workspaces/B6EEE0522721D212/join?email=bernhard.josephus@gmail.com).

Opening the join link will send a join request and the user will be navigated to the WS list as expected. https://github.com/Expensify/App/blob/987ff1b536f2144e5fd492c6d2d2aa621d68442f/src/pages/workspace/WorkspaceJoinUserPage.tsx#L53-L60

The real problem here is that, the WS that we are trying to join doesn't appear on the WS list page. It's because we are filtering any policy that doesn't have role. https://github.com/Expensify/App/blob/987ff1b536f2144e5fd492c6d2d2aa621d68442f/src/libs/PolicyUtils.ts#L183-L188

It's to solve this issue. A WS that we are trying to join only have this information.

image

Because there is no role information, the policy isn't shown.

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

If we look at the shouldShowPolicy condition, we already check for isJoinRequestPending to make sure any pending join WS still included on the list, but since the introduction of the role checking, this issue started to happen.

https://github.com/Expensify/App/blob/987ff1b536f2144e5fd492c6d2d2aa621d68442f/src/libs/PolicyUtils.ts#L183-L188

I think if a WS is pending join, then we can always show it, skipping the other conditions.

return (
    !!policy?.isJoinRequestPending ||
    (!!policy &&
        policy?.type !== CONST.POLICY.TYPE.PERSONAL &&
        (isOffline || policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || Object.keys(policy.errors ?? {}).length > 0) &&
        !!getPolicyRole(policy, currentUserLogin))
);
image
melvin-bot[bot] commented 5 days ago

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

melvin-bot[bot] commented 5 days ago

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

sobitneupane commented 2 days ago

Thanks for the proposal @bernhardoj

Proposal from @bernhardoj looks good to me.

🎀 👀 🎀 C+ reviewed

melvin-bot[bot] commented 2 days ago

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

adelekennedy commented 5 hours ago

little bump @neil-marcellini for the internal review