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
2.99k stars 2.5k forks source link

[HOLD for payment 2024-05-06] [$250] Workspace - Name RHP stays open while not found view is loading #40488

Closed lanitochka17 closed 1 week ago

lanitochka17 commented 1 month 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.63-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: Slack conversation:

Issue found when executing PR https://github.com/Expensify/App/pull/36409

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Create a workspace
  3. Go to workspace settings > Profile > Name
  4. While the RHP is open click on URL and change the workspace ID to something invalid
  5. Navigate to it (e.g https://staging.new.expensify.com/settings/workspaces/<invalid ID>/profile)

Expected Result:

The profile name RHP should close while not found view is loading

Actual Result:

The profile name RHP first closes and then re appears while the not found view is loading

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/78819774/4f27c10f-e630-4dad-94d3-3a02b07739e1

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012247865ed0caacd0
  • Upwork Job ID: 1782481496034230272
  • Last Price Increase: 2024-04-22
  • Automatic offers:
    • Pujan92 | Reviewer | 0
    • nkdengineer | Contributor | 0
melvin-bot[bot] commented 1 month ago

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

lanitochka17 commented 1 month ago

@abekkala FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

lanitochka17 commented 1 month ago

We think that this bug might be related to #wave-collect - Release 1

Nodebrute commented 1 month ago

Proposal

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

Name RHP stays open while not found view is loading

What is the root cause of that problem?

After testing, it appears that this error is not limited to the profile page; it also occurs on the description page. There is currently no logic implemented to handle the not-found page scenario. https://github.com/Expensify/App/blob/68e69623a8bca0dce5f384fa351d5cbb2214aeb4/src/pages/workspace/WorkspaceProfileDescriptionPage.tsx#L70-L78 https://github.com/Expensify/App/blob/68e69623a8bca0dce5f384fa351d5cbb2214aeb4/src/pages/workspace/WorkspaceNamePage.tsx#L56-L64

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

We can implement it similarly to how we're handling the currency selector in the workspace. https://github.com/Expensify/App/blob/68e69623a8bca0dce5f384fa351d5cbb2214aeb4/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx#L78-L83

We can do something like this

 <FullPageNotFoundView
onBackButtonPress={PolicyUtils.goBackFromInvalidPolicy}
  onLinkPress={PolicyUtils.goBackFromInvalidPolicy}
  shouldShow={(isEmptyObject(policy))|| !PolicyUtils.isPolicyAdmin(policy) || PolicyUtils.isPendingDeletePolicy(policy)}
 subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}
            >

Result

https://github.com/Expensify/App/assets/93134676/ab2c837a-4e96-41b7-97a5-54ca52e3790f

What alternative solutions did you explore? (Optional)

We need to test other areas to see if the bug occurs elsewhere as well. Regarding the loading indicator, we can utilize withPolicyAndFullscreenLoading if we decide to include it. However, currently, we're fine without it.

melvin-bot[bot] commented 3 weeks ago

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

melvin-bot[bot] commented 3 weeks ago

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

abekkala commented 3 weeks ago

@Pujan92 we have received a proposal for this one

nkdengineer commented 3 weeks ago

Proposal

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

The profile name RHP first closes and then re appears while the not found view is loading

What is the root cause of that problem?

We don't have any logic to guard the WorkspaceNamePage here against unauthorized access.

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

This is a common use cases for which a dedicated wrapper AdminPolicyAccessOrNotFoundWrapper has been built. It was used everywhere in the same RHP cases like WorkspaceTagsSettingsPage, WorkspaceCreateTaxPage, ...

Not only does it handle showing the correct NotFound based on user's access, but it also has correct goBack logic when we click on back button here (if the workspace is accessible, go back to the workspace profile page, otherwise go to workspace list page). Which will not be available if we use a duplicated FullPageNotFoundView ourselves.

We should use AdminPolicyAccessOrNotFoundWrapper it in WorkspaceNamePage and other pages that are missing it. If we need to customize the subtitle, onLinkPress or other props, we can pass custom param to AdminPolicyAccessOrNotFoundComponent and in AdminPolicyAccessOrNotFoundComponent pass it to the underlying not found page.

For example, if we want to customize to use workspace.common.notAuthorized as the subtitle if policy exists but the user doesn't have admin access, like here, we can add a subtitleKey prop to AdminPolicyAccessOrNotFoundWrapper and pass it to FullPageNotFoundView and NotFoundPage inside. Or we can even make this behavior (custom message if policy exists but don't have access) a default behavior of AdminPolicyAccessOrNotFoundWrapper, and don't need the custom prop.

(Besides the above, we might need to use withPolicyAndFullscreenLoading to wrap the WorkspaceNamePage similar to other pages that use AdminPolicyAccessOrNotFoundWrapper)

What alternative solutions did you explore? (Optional)

For pages that currently use custom FullPageNotFoundView instead of the standardized AdminPolicyAccessOrNotFoundWrapper, like WorkspaceProfileCurrencyPage, we can optionally refactor to use AdminPolicyAccessOrNotFoundWrapper

Pujan92 commented 3 weeks ago

Thanks for the proposals.

Indeed, AdminPolicyAccessOrNotFoundWrapper is the wrapper created specifically for this purpose. Using AdminPolicyAccessOrNotFoundWrapper and customizing it for the subtitle and other required fields(if any) makes more sense to me. Considering that, I am inclined to select @nkdengineer 's proposal over @Nodebrute's proposal. For all workspace pages add AdminPolicyAccessOrNotFoundWrapper where it is missing and replace FullPageNotFoundView with AdminPolicyAccessOrNotFoundWrapper to make it consistent across all workspace related pages.

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

melvin-bot[bot] commented 3 weeks ago

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

melvin-bot[bot] commented 3 weeks ago

πŸ“£ @Pujan92 πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 3 weeks ago

πŸ“£ @nkdengineer πŸŽ‰ 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 πŸ“–

nkdengineer commented 3 weeks ago

I'll raise PR soon

melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.4.67-7 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-05-06. :confetti_ball:

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

melvin-bot[bot] commented 2 weeks 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:

abekkala commented 2 weeks ago

PAYMENT SUMMARY FOR MAY 06

rlinoz commented 2 weeks ago

friendly bump @Pujan92

Pujan92 commented 2 weeks ago

I think a checklist is not needed here as none of the specific PR caused this.

Pujan92 commented 2 weeks ago

Regression Test Steps

  1. Goto your workspace -> Profile
  2. Click on the name which opens the RHP for editing the name
  3. In the URL modify the workspace id with any invalid one and hit enter
  4. Verify that not found view is displayed
abekkala commented 1 week ago

@Pujan92 please accept the offer in Upwork and I can process payment - thanks!

abekkala commented 1 week ago

@nkdengineer payment sent and contract ended - thank you! πŸŽ‰

Pujan92 commented 1 week ago

@abekkala Accepted, Thanks!

abekkala commented 1 week ago

@Pujan92 payment sent and contract ended - thank you!

melvin-bot[bot] commented 1 week ago

@rlinoz @abekkala Be sure to fill out the Contact List!