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

Show errors after workspace creation failure #12117

Merged
merged 10 commits into from
Nov 1, 2022

Conversation

Justicea83
Copy link
Contributor

@Justicea83 Justicea83 commented Oct 25, 2022

Details

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/236995

Tests

Changes For Testing

diff --git a/lib/PolicyAPI.php b/lib/PolicyAPI.php
index 51a480c4f4d..5ba7b05efec 100644
--- a/lib/PolicyAPI.php
+++ b/lib/PolicyAPI.php
@@ -52,6 +52,7 @@ class PolicyAPI
                                   string $adminsChatReportID = '',
                                   string $expenseChatReportID = ''): array
     {
+        self::sayHello();
         $user = User_Store::get($authToken);
         $email = $user->getEmail();
         $callerEmail = $email;
(END)
  1. Signin to NewDot.
  2. If you don't have a workspace yet click on the + button > Create Workspace else skip to 3.
  3. Click on your profile picture.
  4. Click on any workspace.
  5. Click on the elipses(...) > New Workspace.
  6. Ensure you see an error like in the screenshot below.
  7. Click on x to dismiss the error and ensure the workspace is removed(Not showing in the list).

QA Steps

  1. Sign to OldDot as the domain admin(with a domain admin account).
  2. Go to Settings > Domains > Groups.
  3. Click on any group and turn Restrict expense policy creation/removal on.
  4. Signin to NewDot with the account of any user on the group in step 3 that you turned Restrict expense policy creation/removal on.
  5. If you don't have a workspace yet click on the + button > Create Workspace else skip to 3.
  6. Click on your profile picture.
  7. Click Workspaces.
  8. Click on the elipses(...) > New Workspace.
  9. Ensure workspace creation fails with RBR like in the screenshot below.
  10. Click on x to dismiss the error and ensure the workspace is removed(Not showing in the list).

Screenshot 2022-11-08 at 4 44 43 PM

PR Review Checklist

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots

Web

2022-10-31_09-29-59.mp4

Mobile Web - Chrome

2022-10-31_09-30-55.mp4

Mobile Web - Safari

2022-10-31_09-32-05.mp4

Desktop

2022-10-31_09-35-03.mp4

iOS

2022-10-31_09-53-49.mp4

Android

2022-10-26_17-50-32.mp4

@Justicea83 Justicea83 self-assigned this Oct 25, 2022
@Justicea83 Justicea83 changed the title Show errors after workspace creation failure [Hold Offline Testing]Show errors after workspace creation failure Oct 25, 2022
@Justicea83 Justicea83 changed the title [Hold Offline Testing]Show errors after workspace creation failure [Hold Offline Testing & Web-E#35285]Show errors after workspace creation failure Oct 25, 2022
@Justicea83
Copy link
Contributor Author

There was an awkward behaviour with the offline testing, so I'll wait for this PR to be merged before I continue with this.

@Justicea83 Justicea83 changed the title [Hold Offline Testing & Web-E#35285]Show errors after workspace creation failure [Hold Offline & Mobile Testing & Web-E#35285]Show errors after workspace creation failure Oct 26, 2022
@Justicea83 Justicea83 changed the title [Hold Offline & Mobile Testing & Web-E#35285]Show errors after workspace creation failure [Hold Web-E#35285]Show errors after workspace creation failure Oct 27, 2022
@Justicea83 Justicea83 marked this pull request as ready for review October 27, 2022 08:38
@Justicea83 Justicea83 requested a review from a team as a code owner October 27, 2022 08:38
@Justicea83
Copy link
Contributor Author

Awkward behaviour fixed, after the PR was merged.

@Justicea83 Justicea83 requested review from a team and removed request for a team October 27, 2022 09:38
@melvin-bot melvin-bot bot requested review from parasharrajat and tgolen and removed request for a team October 27, 2022 09:38
@tgolen
Copy link
Contributor

tgolen commented Oct 27, 2022

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

image

Mobile Web - Chrome

image

Mobile Web - Safari

image

Desktop

image

iOS

image

Android

image

tgolen
tgolen previously approved these changes Oct 27, 2022
@tgolen
Copy link
Contributor

tgolen commented Oct 27, 2022

I did run into an odd UX while testing this. Probably not blockers for this specific PR, but things that are still weird in the overall flow that you might want to look into.

Issue One

  1. Create the workspace (making sure the server threw an error on creation)
  2. Right away in the app, there is no indication that anything went wrong because you land on the workspace settings page and everything looks normal
  3. If you close the settings modal, or click the back button to return to the list of workspaces, that's when you see the RBR

It would be great if we could show the RBR on the workspace settings page, and perhaps leave all options disabled if there was an error on creation.

Issue Two

  1. Create the workspace (making sure the server threw an error on creation)
  2. Go to the Manage Members setting
  3. The page shows an error saying "the page is nowhere to be found"
  4. If you click < or X, then you are returned to the LHN with no RBR and the failed workspace is not listed in the profile menu any more

@parasharrajat
Copy link
Member

Do you need C+ review here?

@tgolen
Copy link
Contributor

tgolen commented Oct 27, 2022

You can review it if you want. No need to do all the testing though

@Justicea83
Copy link
Contributor Author

@tgolen , I updated the logic to make the children non interactive when creation fails. You can take a look/test.

@Justicea83 Justicea83 requested a review from tgolen October 27, 2022 16:50
@parasharrajat
Copy link
Member

I am busy with stuff so I will let it go. Thanks.

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for disabling those!

src/pages/workspace/WorkspaceInitialPage.js Outdated Show resolved Hide resolved
src/pages/workspace/WorkspaceInitialPage.js Outdated Show resolved Hide resolved
@Justicea83
Copy link
Contributor Author

The PR for workspace list was merged, which meant I needed to tweak this, you can join in on the conversation here regarding a few concerns.

@Justicea83 Justicea83 requested a review from tgolen October 28, 2022 11:32
@Justicea83
Copy link
Contributor Author

@tgolen I removed the RBR on the workspace list item, you can review again/test.

@tgolen
Copy link
Contributor

tgolen commented Oct 28, 2022

Recent tests

Screenshots/Videos

Web

image

Mobile Web - Chrome

image

Mobile Web - Safari

image

Desktop

image

iOS

image

Android

image

@Justicea83
Copy link
Contributor Author

I'll update the PR description with the latest tests videos

@Justicea83 Justicea83 changed the title [Hold Web-E#35285]Show errors after workspace creation failure Show errors after workspace creation failure Nov 1, 2022
@Justicea83 Justicea83 merged commit 5ebbde0 into main Nov 1, 2022
@Justicea83 Justicea83 deleted the justice-refactor-create-workspace branch November 1, 2022 18:50
@OSBotify
Copy link
Contributor

OSBotify commented Nov 1, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Nov 2, 2022

🚀 Deployed to staging by @Justicea83 in version: 1.2.23-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@kavimuru
Copy link

kavimuru commented Nov 3, 2022

@Justicea83 We are not getting error when creating workspace. Is there any steps to trigger the workspace creation failure error?

@@ -122,7 +127,6 @@ class WorkspacesListPage extends Component {
brickRoadIndicator: PolicyUtils.getPolicyBrickRoadIndicatorStatus(policy, this.props.policyMembers),
pendingAction: policy.pendingAction,
isPolicy: true,
errors: policy.errors,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change caused a regression

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see any discussion about this change on this PR. Going to remove it and perform all the testing steps again to see if it can be safely added back

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a discussion on this. We wanted to only show the error message on the workspace details page. Like in this video.

2022-10-31_09-35-03.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now understand the context of that thread, and can see that my fix wasn't what was agreed upon in that thread. However, this PR didn't achieve what was agreed upon in that thread either. It was still a regression – we forgot to test the delete workspace flow with this PR. In that case, the workspace was just not showing at all, so there was no way to dismiss the red dot error that appeared in the settings menu.

@OSBotify
Copy link
Contributor

OSBotify commented Nov 4, 2022

🚀 Deployed to production by @Julesssss in version: 1.2.23-9 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

* @returns {Boolean}
*/
hasPolicyCreationError() {
return Boolean(this.props.policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && this.props.policy.errors);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above logic caused issue:

because optimistic / success data is setting requiresCategory to null, therefore policy.errors will always be true.

App/src/libs/actions/Policy.ts

Lines 3571 to 3599 in 942c851

optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
requiresCategory,
errors: {
requiresCategory: null,
},
pendingFields: {
requiresCategory: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
errors: {
requiresCategory: null,
},
pendingFields: {
requiresCategory: null,
},
},
},
],

The proposed and implemented solution to fix this was to check !isEmptyObject(policy.errors) instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants