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

Remove all uses of actorEmail as part of personalDetails migration #21874

Merged
merged 15 commits into from
Jul 5, 2023

Conversation

Beamanator
Copy link
Contributor

@Beamanator Beamanator commented Jun 29, 2023

cc @puneetlath - this is just another step along our way to completely remove email addresses from reportActions

Details

As part of the personalDetails migration, I removed any uses of reportAction_*.actorEmail.

  • If we hadn't already, I replaced those with uses of actorAccountID

Fixed Issues

$ Related to #19007

Tests

The changes in this PR are mainly to tests or generic changes. Other changes were mainly related to threads & tasks so I'll focus on testing those for this PR.

  1. Make sure thread avatars work well still
    1. Send a message to an account that doesn't have an avatar
    2. Create a thread on that message
    3. Verify you & the other account see that the thread has the same avatar as your own
    4. As the other account, send a chat to your first account
    5. As your first account, create a thread off of the other user's message
    6. Verify you & the other account see that the thread has the same avatar as the "other account"
  2. Make sure creating tasks still works well
    1. Create task via global create & assign someone to the chat
    2. Verify the avatars show up as expected (assignee & where the task is shared)
    3. Verify you're navigate to the task report, and you can easily get back to the parent by clicking "from " in the report header
  • 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
    • 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 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
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

@Beamanator Beamanator requested a review from a team as a code owner June 29, 2023 13:37
@Beamanator Beamanator self-assigned this Jun 29, 2023
@Beamanator Beamanator changed the title Remove all users of actor mail Remove all users of actorEmail Jun 29, 2023
@melvin-bot melvin-bot bot requested review from puneetlath and removed request for a team June 29, 2023 13:38
@melvin-bot
Copy link

melvin-bot bot commented Jun 29, 2023

@puneetlath 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]

@Beamanator Beamanator marked this pull request as draft June 29, 2023 13:41
@Beamanator Beamanator changed the title Remove all users of actorEmail Remove all uses of actorEmail Jun 29, 2023
@Beamanator Beamanator changed the title Remove all uses of actorEmail Remove all uses of actorEmail as part of personalDetails migration Jun 29, 2023
@Beamanator Beamanator marked this pull request as ready for review June 29, 2023 14:03
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
src/libs/actions/Task.js Outdated Show resolved Hide resolved
@Beamanator
Copy link
Contributor Author

@puneetlath addressed comments & fixed merge conflicts!

@0xmiros
Copy link
Contributor

0xmiros commented Jun 30, 2023

reviewing as per request

@puneetlath puneetlath requested a review from 0xmiros June 30, 2023 14:32
@Beamanator Beamanator requested review from puneetlath and 0xmiros July 3, 2023 10:33
@Beamanator
Copy link
Contributor Author

@0xmiroslav @puneetlath ready for re-review 🙏

@puneetlath
Copy link
Contributor

@0xmiroslav please take the first pass.

@@ -74,7 +74,7 @@ function ReportActionItemSingle(props) {
const actorAccountID = props.action.actorAccountID;
let {displayName} = props.personalDetailsList[actorAccountID] || {};
const {avatar, pendingFields} = props.personalDetailsList[actorAccountID] || {};
let actorHint = lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '');
let actorHint = displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we get email here from personal details list and if email is not present then fallback to login?
I think here we are trying to remove prefix from merged accounts emails

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Juuuust to be clear @MonilBhavsar do you mean, we should check the login from personalDetailsList first - and if that doesn't exist, we fall back to displayName?

If that's what you meant, then yes I agree :D

Copy link
Contributor

Choose a reason for hiding this comment

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

displayName from personalDetailsList always fallback to login if display name is not set, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

do you mean, we should check the login from personalDetailsList first - and if that doesn't exist, we fall back to displayName?

Yes correct! Exactly what I mean :D

displayName from personalDetailsList always fallback to login if display name is not set, isn't it?

Yes, in case display name is set it won't be login. And in that line we specifically want to process login(email). So we can first check if login exists, if not we can fallback to displayName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

displayName from personalDetailsList always fallback to login if display name is not set, isn't it?

Technically no, not always - for example in OpenPublicProfilePage we won't default their displayName to login since you shouldn't know that at that point

@0xmiros
Copy link
Contributor

0xmiros commented Jul 4, 2023

Conflict arrived

@Beamanator
Copy link
Contributor Author

Conflict fixed, @MonilBhavsar addressed your comment 👍

@0xmiros
Copy link
Contributor

0xmiros commented Jul 4, 2023

Followed by lint failure 😁

@Beamanator
Copy link
Contributor Author

Lint fixed 😅 Hopefully tests pass 🙏

@Beamanator
Copy link
Contributor Author

Yep checks look happy, @MonilBhavsar @puneetlath @MariaHCD any of y'all wanna approve & merge? 🙏

@@ -251,7 +259,7 @@ function reopenTask(taskReportID, taskTitle) {
statusNum: CONST.REPORT.STATUS.OPEN,
lastVisibleActionCreated: reopenedTaskReportAction.created,
lastMessageText: message,
lastActorEmail: reopenedTaskReportAction.actorEmail,
lastActorEmail: currentUserEmail,
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, I think we should still keep it as reopenedTaskReportAction.actorEmail
In case we change ReportUtils::buildOptimisticTaskReportAction() in future and reopenedTaskReportAction get's updated, this direct reference might introduce some bugs.
Same below

Copy link
Contributor Author

@Beamanator Beamanator Jul 5, 2023

Choose a reason for hiding this comment

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

Hmm I'm keen to completely get rid of actorEmail AND we're getting rid of lastActorEmail in this PR: #22008

So I think we'll keep it like this for now 🙏

@Beamanator Beamanator merged commit 85ce1ed into main Jul 5, 2023
@Beamanator Beamanator deleted the beaman-migrateActorEmail branch July 5, 2023 07:42
@OSBotify
Copy link
Contributor

OSBotify commented Jul 5, 2023

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

@luacmartins
Copy link
Contributor

The App is crashing on main when requesting money from a new user with the error below:

Screenshot 2023-07-05 at 9 21 29 AM

Fix here

@OSBotify
Copy link
Contributor

OSBotify commented Jul 5, 2023

🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.37-0 🚀

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

@iwiznia
Copy link
Contributor

iwiznia commented Jul 5, 2023

This caused a regression. See #22286 (comment)

@0xmiros
Copy link
Contributor

0xmiros commented Jul 5, 2023

This is a good example why we should always retest after merging from main.
We had deprecated actorEmail in canFlagReportAction but in #22099, they changed position of this function and made this PR conflict.

@luacmartins
Copy link
Contributor

@Beamanator I closed my fix PR since we're reverting this

@Beamanator
Copy link
Contributor Author

Welp looks like this was fixed in #22269 so I'll make an un-revert & add @luacmartins 's changes to make sure we're good to go on the next one 🙏 Thanks everyone!

@Beamanator
Copy link
Contributor Author

Re-do PR is up here: #22327

@OSBotify
Copy link
Contributor

OSBotify commented Jul 7, 2023

🚀 Deployed to production by https://github.com/Julesssss in version: 1.3.37-7 🚀

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

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