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

Add notification preference for all the reports and update the design for the group chats #28200

Merged
merged 22 commits into from
Oct 10, 2023

Conversation

techievivek
Copy link
Contributor

@techievivek techievivek commented Sep 25, 2023

Details

Here are a few things that got updated in this PR.

  1. We updated the details page for the group chat.
  2. We show the settings pages for all the chat reports.
  3. We allow all the chat reports to set the notification preference.

Fixed Issues

$ #27394
PROPOSAL: N/A

Tests

Needs to be tested with this Web-E PR: https://github.com/Expensify/Web-Expensify/pull/38977

  1. Test for DM chat report
  • Login to newDot as userA on one device/browser.
  • Login to newDot as userB on another device/browser.
  • Create a DM chat report with userB.
  • Write a new message to userB and confirm that they receive a notification.
  • Update the notification preference as userB to daily and confirm you no longer see the notification.
  1. Test for workspace private/restricted rooms
  • Login to newDot as userA on one device/browser.
  • Login to newDot as userB on another device/browser.
  • Create a new workspace and invite the userB to it.
  • Write a new message to in any of the private/default/restricted room and confirm that the userB receives a notification.
  • Update the notification preference as userB to daily and confirm you no longer see the notification.
  1. Test for group DM chat
  • Login to newDot as userA on one device/browser.
  • Login to newDot as userB on another device/browser.
  • Create a group DM chat report with userB and bunch of other users.
  • Write a new message in the chat and confirm userB received a notification.
  • Update the notification preference as userB to daily and confirm you no longer see the notification.
  1. Test for workspace public rooms
  • Login to newDot as userA on one device/browser.

  • Login to newDot as userB on another device/browser.

  • Create a new workspace and create a new public room.

  • As userA, write a few message to the room.

  • As userB, join the above public room.

  • As userA, write few more new message and confirm userB don't receive a notification.

  • Update the notification preference for userB to always and confirm they receive a notification.

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

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 the expected offline behavior in the Offline steps 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 tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is 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
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • 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.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web Screenshot 2023-09-27 at 9 07 29 AM Screenshot 2023-09-27 at 9 08 43 AM Screenshot 2023-09-27 at 9 09 32 AM
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

@techievivek techievivek self-assigned this Sep 25, 2023
@techievivek techievivek marked this pull request as ready for review September 27, 2023 00:42
@techievivek techievivek requested a review from a team as a code owner September 27, 2023 00:42
@melvin-bot melvin-bot bot requested review from mollfpr and removed request for a team September 27, 2023 00:42
@melvin-bot
Copy link

melvin-bot bot commented Sep 27, 2023

@mollfpr Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@techievivek
Copy link
Contributor Author

techievivek commented Sep 27, 2023

@mollfpr I am also working from Bali 😄. Let me know if the changes look good to you. I will add the videos by then. If you have questions, you can put them here, and we can resolve them quickly. Looking to get this shipped ASAP as it is a wave8 priority.

@techievivek
Copy link
Contributor Author

Added @arosiclair for review as he is assigned to review the web-e changes.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 27, 2023

Take the review now!!!

@techievivek Really?? I didn't see you in the 10am spot in Ubud 😅

@techievivek
Copy link
Contributor Author

@mollfpr I only joined for the last week 😢, so now we are working from Jimbaran.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 27, 2023

@techievivek Is the Web-E PR in staging?

@MitchExpensify
Copy link
Contributor

Thank you for prioritizing this @mollfpr, this is an important piece of an external deadline project so your help is super appreciated!

Copy link
Contributor

@mollfpr mollfpr left a comment

Choose a reason for hiding this comment

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

Mostly looks good.

src/pages/ProfilePage.js Outdated Show resolved Hide resolved
@mollfpr
Copy link
Contributor

mollfpr commented Sep 27, 2023

@techievivek The selected option is not changed on the profile page.

Screen.Recording.2023-09-27.at.10.36.04.mov

@techievivek
Copy link
Contributor Author

@mollfpr Aaah sorry the backend changes are not yet live, do you want me to share my ngrok URL so you can test them?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 27, 2023

@techievivek That's would be great!

@techievivek
Copy link
Contributor Author

techievivek commented Sep 27, 2023

@mollfpr I am looking at your videos and it looks like this should have worked because it doesn't seem to actually depend on the backend changes. Do you mind sharing the onyx response for the request. Does it include the updated notification preference for the report?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 27, 2023

Tested with your ngrok. The response seems fine, but the selected value doesn't change.

Screenshot 2023-09-27 at 11 29 28

Screen.Recording.2023-09-27.at.11.27.56.mov

@mollfpr
Copy link
Contributor

mollfpr commented Sep 27, 2023

I think the issue is because the page is not re-render after selecting the preference.

@techievivek
Copy link
Contributor Author

@mollfpr How is it going? Let me know if you are stuck anywhere or need help with anything, thanks.

Copy link
Contributor

@mollfpr mollfpr left a comment

Choose a reason for hiding this comment

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

Sorry @techievivek I forgot to approve the PR. The changes looks good and it tests well on Web, Desktop and Android. I still uploading the recordings to the checklist.

@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

@hayata-suenaga Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@techievivek
Copy link
Contributor Author

@arosiclair Can you please give this a review so we can get this merged today.

@techievivek
Copy link
Contributor Author

🤦 We are once again in the conflict zone, let me resolve them quickly. @mollfpr can you please add the ios recordings for any single test(just for DM).

@mollfpr
Copy link
Contributor

mollfpr commented Oct 10, 2023

@techievivek Sure!

@hayata-suenaga
Copy link
Contributor

@hayata-suenaga Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it.

I think the checklist is already done by @mollfpr. @arosiclair is assigned as an internal engineer. melvin, why did you assign me???

Anyway, I'm unassigning myself

@hayata-suenaga hayata-suenaga removed their request for review October 10, 2023 05:57
key: ONYXKEYS.SESSION,
},
}),
// eslint-disable-next-line rulesdir/no-multiple-onyx-in-file
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand that comment, but it sounds like there's urgency behind this so I won't be a blocker. However, can we create a follow up issue to clean this up and remove the need for a second Onyx subscription? I'm not sure exactly how it should be cleaned up but it definitely doesn't need to be like this. Thanks!

@techievivek techievivek merged commit a63f853 into main Oct 10, 2023
16 checks passed
@techievivek techievivek deleted the techievivek_add_notif_pref_all branch October 10, 2023 09:12
@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.

@techievivek
Copy link
Contributor Author

@arosiclair Created one here for the cleanup/improvements: #29165

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/techievivek in version: 1.3.81-0 🚀

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

Comment on lines +311 to +314
if (Number(session.accountID) === accountID || Session.isAnonymousUser()) {
return null;
}
return `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '')}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused regression when user opens new user profile link first time.
This happens because report_ returning all reports.
We should fix this by setting report_0 or report_null or null

Suggested change
if (Number(session.accountID) === accountID || Session.isAnonymousUser()) {
return null;
}
return `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '')}`;
const reportID = lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '');
if (Number(session.accountID) === accountID || Session.isAnonymousUser() || !reportID) {
return null;
}
return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`;

Right now, app crashes and will be a deploy blocker soon

Screenshot 2023-10-11 at 10 51 16 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

raised PR for the quick fix

@@ -61,8 +61,7 @@ const defaultProps = {
function ReportDetailsPage(props) {
const policy = useMemo(() => props.policies[`${ONYXKEYS.COLLECTION.POLICY}${props.report.policyID}`], [props.policies, props.report.policyID]);
const isPolicyAdmin = useMemo(() => PolicyUtils.isPolicyAdmin(policy), [policy]);
const shouldDisableSettings = useMemo(() => ReportUtils.shouldDisableSettings(props.report), [props.report]);
const shouldUseFullTitle = !shouldDisableSettings || ReportUtils.isTaskReport(props.report);
const shouldUseFullTitle = ReportUtils.isTaskReport(props.report);
Copy link
Contributor

@situchan situchan Oct 11, 2023

Choose a reason for hiding this comment

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

Is there reason for removing !shouldDisableSettings || condition here?
This caused regression - #29321

Edit: Ah I think I got answer here

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/techievivek in version: 1.3.83-0 🚀

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

const shouldDisableSettings = _.isEmpty(report) || ReportUtils.shouldDisableSettings(report) || ReportUtils.isArchivedRoom(report);
const shouldDisableSettings = _.isEmpty(report) || ReportUtils.isArchivedRoom(report);
Copy link
Contributor

Choose a reason for hiding this comment

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

After enabling settings for all the reports and revealing access to the notification preference page. We had to test the offline behavior for the newly enabled reports. Coming from #29334 this caused a regression where the creation of a new task missed the optimistic prop notificationPreference.

if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report) || isTaskReport(report) || isMoneyRequestReport(report)) {
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID));
return;
}
if (participantAccountIDs.length === 1) {
if (isDM(report) && participantAccountIDs.length === 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This created a regression which is fixed in #30182

if (Number(session.accountID) === accountID || Session.isAnonymousUser()) {
return null;
}
return `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '')}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

You haven't taken into account the dependency of getChatByParticipants on reports which caused #35654

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.

10 participants