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

Updated code to remove dependency on IS_LOADING_POLICY_DATA for Welcome.js #11627

Merged
merged 7 commits into from
Oct 20, 2022

Conversation

techievivek
Copy link
Contributor

@techievivek techievivek commented Oct 6, 2022

Details

In Welcome.js remove the usage of IS_LOADING_POLICY_DATA because report and policy data are loaded together so we can just rely on IS_LOADING_REPORT_DATA to trust that both report and policy data are available.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/211216
PROPOSAL: GH_LINK_ISSUE(COMMENT)

Tests

  1. Create a new workspace from an account that's on the policyExpenseChat beta (e.g @expensifail.com) since for DEV every beta is enabled by default we can use any account.
  2. To this newly created workspace added a member by going to Manage Members > Invite.
  3. CMD+F and search the member's name to navigate to their workspace chat. (It could be that you will not find the workspace chat so you can just refresh the app and that should load the workspace chat).
    The workspace chat would look something like this.

Screenshot 2022-10-06 at 3 11 02 PM

  1. Write a couple of messages in the member's workspace chat, then log out of the admin account.
  2. Validated the newly added member account and logged in to NewDot. On DEV you will use ./clitools.sh on PROD you can click on the email.
  3. We now land in the workspace chat and we are able to see the messages sent by the admin.
  • Verify that no errors appear in the JS console

QA Steps

  1. Create a new workspace from an account that's on the policyExpenseChat beta (e.g @expensifail.com).
  2. To this newly created workspace added a member by going to Manage Members > Invite.
  3. CMD+F and search the member's name to navigate to their workspace chat. (It could be that you will not find the workspace chat so you can just refresh the app and that should load the workspace chat).
    The workspace chat would look something like this.

Screenshot 2022-10-06 at 3 11 02 PM

  1. Write a couple of messages in the member's workspace chat, then log out of the admin account.
  2. Validated the newly added member account and log in to NewDot.
  3. Make sure you land in the workspace chat.
  • Verify that no errors appear in the JS console

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

Screen.Recording.2022-10-06.at.3.14.57.PM.mov

Mobile Web - Chrome

Screen.Recording.2022-10-10.at.2.47.55.PM.mov

Mobile Web - Safari

ios-safari.mov

Desktop

desktop.mov

iOS

ios.mov

Android

android.mov

@techievivek techievivek self-assigned this Oct 6, 2022
@techievivek techievivek requested a review from a team as a code owner October 6, 2022 09:50
@melvin-bot melvin-bot bot requested review from bondydaa and removed request for a team October 6, 2022 09:50
@techievivek techievivek force-pushed the techievivek_workspace_chat_for_first_time_user branch from b1a0ee9 to fc1669c Compare October 6, 2022 09:59
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

We are intentionally removing the IS_LOADING_POLICY_DATA key. Instead of adding it back, I'd suggest that we remove the Welcome event's dependency on it.

@techievivek techievivek changed the title Updated code to include status of loading policy data for openApp Updated code to remove dependency on IS_LOADING_POLICY_DATA for Welcome.js Oct 11, 2022
Copy link
Contributor

@bondydaa bondydaa left a comment

Choose a reason for hiding this comment

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

Looks like the only other spots we use that Onyx key is here

function getPolicyList() {
Onyx.set(ONYXKEYS.IS_LOADING_POLICY_DATA, true);
DeprecatedAPI.GetPolicySummaryList()
.then((data) => {
if (data.jsonCode !== 200) {
Onyx.set(ONYXKEYS.IS_LOADING_POLICY_DATA, false);
return;
}
const policyCollection = _.reduce(data.policySummaryList, (memo, policy) => ({
...memo,
[`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`]: getSimplifiedPolicyObject(policy, false),
}), {});
if (!_.isEmpty(policyCollection)) {
updateAllPolicies(policyCollection);
}
Onyx.set(ONYXKEYS.IS_LOADING_POLICY_DATA, false);
});
}
so we can we just fully kill this key and code?

Comment on lines 124 to 125
},
],
Copy link
Contributor

Choose a reason for hiding this comment

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

strange I thought we'd prefer what was there before (}]) did the linter complain about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 I think the other way reads better. Same for the others.

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

I agree with Bondy's comments. Let's revert the style changes in actions/App and remove this code and this Onyx key

Comment on lines 124 to 125
},
],
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 I think the other way reads better. Same for the others.

bondydaa
bondydaa previously approved these changes Oct 12, 2022
Copy link
Contributor

@bondydaa bondydaa left a comment

Choose a reason for hiding this comment

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

👍 nice work.

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

Looking good! While reviewing this, I noticed that we might have another bug (not introduced in this PR)

This code is supposed to load all policies, but it actually loads all reports. So the first part of this conditional will probably always be true and admins of workspaces would also see the welcome action.

We can fix that in this PR too!

@techievivek
Copy link
Contributor Author

So the first part of this conditional will probably always be true and admins of workspaces would also see the welcome action

Great catch, since policy data are not loaded this makes sense.

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

@techievivek I had to merge main to be able to see the policy expense chats. The solution seem to work well on web, desktop and mWeb Chrome, but it did not work on android, iOS or mWeb safari.

I see that you had videos with the solution working, so I'm wondering if it's just me holding something wrong. @bondydaa could you try to test this solution in iOS/android?

web.mov
desktop.mov
chrome.mov
android.mov
ios.mov
safari.mov

@techievivek
Copy link
Contributor Author

That's odd, let me try testing it once again and probably adding some log statements to make sure logic is being hit.

@luacmartins
Copy link
Contributor

In the logs, I could see that we were trying to navigate to the correct expense chat report. It might just be some RN navigation quirk.

@techievivek
Copy link
Contributor Author

I struggled with the DEV environment setup yesterday, so couldn't look into it. I will test it today.

@techievivek
Copy link
Contributor Author

I tested this locally and experienced the same thing that @luacmartins experienced. I wasn't able to test this further because of the Pusher limit which didn't allow me to create new accounts on DEV. But this is something that we will have to make sure gets resolved before moving forward.

In the logs, it does show that we will be navigation to the workspace chat but it just freezes.

Screenshot 2022-10-18 at 3 59 01 PM

@luacmartins
Copy link
Contributor

@techievivek this is some quirk with react-navigation. I'd see if anybody in engineeering-chat has some ideas on how to fix this. I had a similar issue not too long ago

@luacmartins
Copy link
Contributor

@techievivek since this is a react navigation issue, I think we should merge this to partially fix the problem and then open another issue to investigate the RN nav issue. Could you please update your branch with main? I'll review it again and merge this PR then.

@techievivek
Copy link
Contributor Author

Alright, I have merged with main now.

@luacmartins
Copy link
Contributor

@techievivek can you update your author checklist? I think that we have a new version and that's why your PR Author checklist check is failing

@techievivek
Copy link
Contributor Author

@luacmartins I have ticked all the options. I am not sure why it is still failing.

@techievivek
Copy link
Contributor Author

@luacmartins, thanks for the note, I have updated the checklists.

@luacmartins
Copy link
Contributor

luacmartins commented Oct 20, 2022

  • 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.
web.mov
desktop.mov
chrome.mov
android.mov
ios.mov
safari.mov

@luacmartins luacmartins merged commit df90010 into main Oct 20, 2022
@luacmartins luacmartins deleted the techievivek_workspace_chat_for_first_time_user branch October 20, 2022 14:54
@luacmartins
Copy link
Contributor

@techievivek I created a new issue for the react navigation quirk on iOS and android and assigned it to you.

@OSBotify
Copy link
Contributor

✋ 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

🚀 Deployed to staging by @luacmartins in version: 1.2.19-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @chiragsalian in version: 1.2.19-2 🚀

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

@marcaaron
Copy link
Contributor

In Welcome.js remove the usage of IS_LOADING_POLICY_DATA because report and policy data are loaded together so we can just rely on IS_LOADING_REPORT_DATA to trust that both report and policy data are available.

Late to the party, but I would have re-named this if we are relaying on a "report data is loading" flag to mean more than just the report data is loading.

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.

5 participants