App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for BE fix] fix: Group is created with duplicate

Open nkdengineer opened this issue 1 year ago • 23 comments

Explanation of Change

Fixed Issues

$ https://github.com/Expensify/App/issues/49931 PROPOSAL: https://github.com/Expensify/App/issues/49931#issuecomment-2395918533

Tests

  1. Open the Developer Tools and go to the Network tab, then set the network speed to 3G
  2. Click on the FAB > Start Chat
  3. Enter a user's email, then quickly click on it before the fallback avatar changes to the correct user avatar
  4. Send a message
  5. Verify that: The chat with the selected user should remain a 1-on-1 chat. The chat should not change into a group with duplicate users
  • [x] Verify that no errors appear in the JS console

Offline tests

same as above

QA Steps

same as above

  • [x] Verify that no errors appear in the JS console

PR Author Checklist

  • [x] I linked the correct issue in the ### Fixed Issues section above
  • [x] I wrote clear testing steps that cover the changes made in this PR
    • [x] I added steps for local testing in the Tests section
    • [x] I added steps for the expected offline behavior in the Offline steps section
    • [x] I added steps for Staging and/or Production testing in the QA steps section
    • [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • [x] 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)
    • [x] 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).
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I ran the tests on all platforms & verified they passed on:
    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop
  • [x] 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)
  • [x] I followed proper code patterns (see Reviewing the code)
    • [x] 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)
    • [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] 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.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • [x] 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:
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • [x] 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.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I followed the guidelines as stated in the Review Guidelines
  • [x] 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)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] 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
  • [x] I verified that if a function's arguments changed that all usages have also been updated correctly
  • [x] If any new file was added I verified that:
    • [x] 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
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • [x] 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.
  • [x] 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)
  • [x] 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.
  • [x] 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.
  • [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • [x] I verified that all the inputs inside a form are aligned with each other.
    • [x] I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • [x] 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.
  • [x] 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.

Screenshots/Videos

Android: Native

https://github.com/user-attachments/assets/57172e2e-2c2f-45d5-aa2a-e8c0fa925b2e

Android: mWeb Chrome
iOS: Native

https://github.com/user-attachments/assets/a0be48ec-d079-42ae-857d-695b695b3d82

iOS: mWeb Safari

https://github.com/user-attachments/assets/82f86993-6f2c-44cf-8ba3-85733ac90a22

MacOS: Chrome / Safari

https://github.com/user-attachments/assets/3a8189e9-362f-4bdf-830e-39d46d9d1270

MacOS: Desktop

https://github.com/user-attachments/assets/aaa349af-8301-4f61-8f63-541737673a3c

nkdengineer avatar Oct 30 '24 04:10 nkdengineer

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

melvin-bot[bot] avatar Oct 30 '24 09:10 melvin-bot[bot]

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:
    • [ ] Android: Native
    • [ ] Android: mWeb Chrome
    • [ ] iOS: Native
    • [ ] iOS: mWeb Safari
    • [ ] MacOS: Chrome / Safari
    • [ ] 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 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
    • [ ] 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • [ ] 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 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(theme.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 the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • [ ] I verified that all the inputs inside a form are aligned with each other.
    • [ ] I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • [ ] 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 reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

DylanDylann avatar Oct 30 '24 09:10 DylanDylann

@nkdengineer I notice that we have a flicker

https://github.com/user-attachments/assets/9367aeb7-2707-4a6a-8d83-3bd61fb7a05f

DylanDylann avatar Oct 30 '24 10:10 DylanDylann

@DylanDylann I fixed this bug. The problem, in this case, is the GetMissingOnyxMessage data is merged before the optimistic personal detail is cleared in queueOnyxUpdate.

nkdengineer avatar Oct 31 '24 02:10 nkdengineer

@nkdengineer Hmmm, I am not sure if your fix is valid

DylanDylann avatar Oct 31 '24 10:10 DylanDylann

@aldo-expensify While reviewing the PR, I see a problem . The RCA is GetMissingOnyxMessage data is merged before we execute the flushOnyxUpdatesQueue function. When GetMissingOnyxMessage data is merged, three avatars display because we haven't removed the optimistic data. Then when flushOnyxUpdatesQueue is executed, the successData is merged and it removes the optimisticData.

So, we have these options here:

  • Leave this bug away, because the flicker only happens if user is on a low network
  • Apply @nkdengineer's fix, which executes flushOnyxUpdatesQueue before merging GetMissingOnyxMessage. With this approach, it can cause a replay effect when GetMissingOnyxMessage updates the same data that is updated by flushOnyxUpdatesQueue
  • We can fix BE to modify the response of GetMissingOnyxMessage API

DylanDylann avatar Oct 31 '24 10:10 DylanDylann

@aldo-expensify While reviewing the PR, I see a problem . The RCA is GetMissingOnyxMessage data is merged before we execute the flushOnyxUpdatesQueue function. When GetMissingOnyxMessage data is merged, three avatars display because we haven't removed the optimistic data. Then when flushOnyxUpdatesQueue is executed, the successData is merged and it removes the optimisticData.

So, we have these options here:

  • Leave this bug away, because the flicker only happens if user is on a low network

When you say "this bug", are you referring to this flickering https://github.com/Expensify/App/pull/51712#issuecomment-2446562109, right? Am I understanding correctly that the changes of this PR are turning the original problem into a short/fast flickering?

  • Apply @nkdengineer's fix, which executes flushOnyxUpdatesQueue before merging GetMissingOnyxMessage. With this approach, it can cause a replay effect when GetMissingOnyxMessage updates the same data that is updated by flushOnyxUpdatesQueue

Do we know of a way of reproducing the "replay effect" that @nkdengineer 's fix would produce? I guess we could try to assess if it would happen and be visible in real use cases vs and compare to the flickering we are trying to fix. If the "replay effect" is worse, then we shouldn't do this for sure. The flickering is barely noticeable.

  • We can fix BE to modify the response of GetMissingOnyxMessage API

How do you think this can be fixed in the backend? by correcting lastUpdateID and previousUpdateID returned by OpenReport and AddComment?

aldo-expensify avatar Nov 01 '24 20:11 aldo-expensify

Hey all 👋 this fixes a deploy blocker so it would be great to get some movement here - are we planning on a backend fix? Or is there a small frontend fix we can get going to fix the blocker? Or can we call the blocker NAB?

Beamanator avatar Nov 04 '24 10:11 Beamanator

Bumping this PR, what's the next step?

Julesssss avatar Nov 11 '24 15:11 Julesssss

The most active thread is this one here: https://github.com/Expensify/App/pull/51712#discussion_r1826249579

Basically, we need to decide if we want to implement a frontend bandaid over a problem caused by Auth using forwardCommand. The use of forwardCommand was to improve the speen of OpenReport, but since it results in this bug, I'm thinking that using forwardCommand is not worth it and I would prefer a slightly slower OpenReport rather than modifying the internals of how the sequential queue works.

tgolen avatar Nov 11 '24 16:11 tgolen

@nkdengineer Please mark this PR on hold BE

DylanDylann avatar Nov 13 '24 05:11 DylanDylann

I'm bringing this conversation to an internal Slack channel to discuss (link).

tgolen avatar Nov 13 '24 16:11 tgolen

OK, it sounds like @aldo-expensify is fixing the lastUpdateID bug on the backend with this PR.

@nkdengineer once that is fixed, will there still need to be more work done in this PR, or can this PR simply be closed without merging?

In other words, I'm confused about if the lastUpdateID bug is the cause of the original problem or not.

tgolen avatar Nov 15 '24 16:11 tgolen

I think we can re-test the issue and some other issues that we're holding from this PR to make sure we can close the PR or continue working on this.

nkdengineer avatar Nov 15 '24 16:11 nkdengineer

All right, sounds good. I'll try to keep this updated to let you know when the BE thing is fixed.

On Fri, Nov 15, 2024 at 9:29 AM nkdengineer @.***> wrote:

I think we can re-test the issue and some other issues that we're holding from this PR to make sure we can close the PR or continue working on this.

— Reply to this email directly, view it on GitHub https://github.com/Expensify/App/pull/51712#issuecomment-2479374069, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJMAB3H5NBQWZUOBUAKFRD2AYONZAVCNFSM6AAAAABQ3IDBYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZZGM3TIMBWHE . You are receiving this because you were mentioned.Message ID: @.***>

tgolen avatar Nov 15 '24 17:11 tgolen

Daily Update

  • The backend PR is still in draft mode
  • @aldo-expensify is continuing to work on it and being careful not to break things (the code is quite complex)

Next Steps

  • @aldo-expensify finish writing the PR and submit it for review
  • Get the PR merged and deployed
  • Re-evaluate this bug

ETA

  • Wed Nev 27

tgolen avatar Nov 20 '24 15:11 tgolen

Daily Update

  • Still not a lot of progress being made on the backend PR, but we are discussing it on Slack to try and find a way forward through the complexity

tgolen avatar Nov 21 '24 15:11 tgolen

Daily Update

  • There was a small breakthrough on the backend PR that should give us a good path forward. It still requires some implementation work.

ETA

  • Wed Nov 27

tgolen avatar Nov 22 '24 16:11 tgolen

Daily Update

  • @aldo-expensify is still diligently making progress on the backend
  • It is getting closer to a fix, but the code is complex and has to handle many different flows, so it is difficult to modify without causing regressions

ETA

  • Wednesday Dec 4

tgolen avatar Nov 26 '24 15:11 tgolen

Daily Update

  • The Auth PR has been taken out of draft mode and is in full review

Next Steps

  • @tgolen @neil-marcellini Review and merge the Auth PR
  • Wait for it to be deployed
  • @nkdengineer re-evaluate this bug to see if it is still happening and what, if any, updates need to be made to this PR

ETA

  • Thursday, Dec 5

tgolen avatar Dec 02 '24 16:12 tgolen

Daily Update

  • The Auth PR has received 2/3 reviews

Next Steps

  • @tylerkaraszewski review and merge the Auth PR
  • Wait for it to be deployed
  • @nkdengineer re-evaluate this bug

ETA

  • Tomorrow, Dec 5

tgolen avatar Dec 04 '24 16:12 tgolen

Daily Update

  • The Auth PR is still not merged yet
  • I'm pushing to have it merged today and dismiss the remaining review

Next Steps

  • @aldo-expensify merge the Auth PR if you're ready
  • Wait for it to be deployed
  • @nkdengineer re-evaluate this bug

ETA

  • Tomorrow, Dec 6

tgolen avatar Dec 05 '24 16:12 tgolen

Daily Update

  • The Auth PR was merged and deployed to production 🎉

Next Steps

  • @nkdengineer can you please re-evaluate this bug now?

tgolen avatar Dec 06 '24 15:12 tgolen

@tgolen The original bug and all related bugs are fixed now.

nkdengineer avatar Dec 09 '24 09:12 nkdengineer

That's really great! Thank you. I think I'll go ahead and close this then, and I think you should get partial payment for the work you've done on this one, even though the PR wasn't merged.

tgolen avatar Dec 09 '24 15:12 tgolen