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

Sort reportActions by created instead of sequenceNumber #12626

Merged
merged 30 commits into from
Dec 1, 2022

Conversation

roryabraham
Copy link
Contributor

@roryabraham roryabraham commented Nov 9, 2022

Details

Start sorting reportActions by their created timestamp, falling back on actionname / type as a secondary comparator in the event of same-millisecond reportActions, and finally falling back on reportActionID as a last comparator in the event of same-millisecond reportActions AND same actionname.

Fixed Issues

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

Tests / QA Steps

  1. Open a chat
  2. Scroll all the way back to the beginning. Verify that you see the report welcome message at the start of the chat.
  3. Send a few messages in the chat.
  4. Verify that the new chats appear in order at the end of the chat.
  5. Turn off your internet
  6. Send a few more messages in the chat.
  7. Those chats should appear as pending while you're offline, but they should appear in the correct order at the end of the chat.
  8. Come back online.
  9. The chats should become finalized and no longer be pending.
  10. Delete a message, verify that it disappears.
  11. Go offline
  12. Delete a message, verify that it appears as "pending deletion" (aka strikethrough)
  13. Come back on line. Verify that the message you deleted while offline disappears.
  • 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:

    • 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

  • 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 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

image

image

image

image

Mobile Web - Chrome

Mobile Web - Safari

Desktop

image

image

image

iOS

Android

Screenshot_20221129-161646

@roryabraham roryabraham self-assigned this Nov 9, 2022
@roryabraham roryabraham marked this pull request as ready for review November 23, 2022 00:34
@roryabraham roryabraham requested a review from a team as a code owner November 23, 2022 00:34
@roryabraham roryabraham changed the title [WIP][HOLD] Sort reportActions by created instead of sequenceNumber Sort reportActions by created instead of sequenceNumber Nov 23, 2022
@melvin-bot melvin-bot bot requested review from danieldoglas and sobitneupane and removed request for a team November 23, 2022 00:35
@melvin-bot
Copy link

melvin-bot bot commented Nov 23, 2022

@sobitneupane @danieldoglas One of you needs to 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]

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

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

Didn't get the expected result. Got following screens while scrolling through previous chats.

Safari:

Screenshot 2022-11-23 at 14 32 07

Chrome:

Screenshot 2022-11-23 at 14 43 16

@roryabraham
Copy link
Contributor Author

@sobitneupane any chance you can provide more details for those chats? Maybe their Onyx data?

@sobitneupane
Copy link
Contributor

I can see a lot of "(edited)" message out of nowhere. But could not reproduce the issue where report welcome message appears in the middle.

Screen.Recording.2022-11-24.at.00.18.30.mov

onyxdata_reportAction.txt

@mountiny
Copy link
Contributor

I thought that was because Pusher messages aren't guaranteed to be received in the order they're sent

If that is the case we are fine.

I can help with the testing tomorrow morning if you wont get to ti, also @sobitneupane if you would be able to get to all platforms

@sobitneupane
Copy link
Contributor

@sobitneupane if you would be able to get to all platforms

I will test it today.

@roryabraham
Copy link
Contributor Author

Brought up the bug in slack here. We can either put this on HOLD or merge and fix it in a follow up. I'd prefer to merge and fix in a follow-up

@sobitneupane
Copy link
Contributor

sobitneupane commented Dec 1, 2022

I was able to reproduce the shuffling issue online as well.

Screen.Recording.2022-12-01.at.11.54.59.mov

@sobitneupane
Copy link
Contributor

sobitneupane commented Dec 1, 2022

On android, message sent offline, appear twice. I noticed similar behavior in mWeb/chrome as well. I was able to reproduce this on IOS as well.

Screen.Recording.2022-12-01.at.11.43.14.mov

@sobitneupane
Copy link
Contributor

sobitneupane commented Dec 1, 2022

Screenshots/Videos

Web
Untitled.mov
Mobile Web - Chrome
Screen.Recording.2022-12-01.at.12.12.57.mov
Mobile Web - Safari
Untitled.mp4
Desktop
Screen.Recording.2022-12-01.at.11.37.42.mov
iOS
RPReplay_Final1669877515.mp4
Android
Screen.Recording.2022-12-01.at.11.43.14.mov

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

I have also experiences the reshuffling while being online which is odd
image

this is just picture but the order of messages sent was 1, 2, 3, 4, 5 as you would expect.

I agree in the slack thread that if this is only in Offline we can do nothing for now, the end state is fine, but this should not happen when being online.

My reproduction steps have been simple, create a new chat and sent the messages in order and then it started to reshuffle, in the end it settles to the correct order but it is not great UX

@mountiny
Copy link
Contributor

mountiny commented Dec 1, 2022

Not sure what is going on but getting this behaviour, things are just really slow but it might be my VM, however, it also could be something else since Sobit experiences the same issue and he points to staging/prod.
https://user-images.githubusercontent.com/36083550/205063221-a3da88af-8c41-474c-91ce-d7851dcae853.mp4

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Alright, I have confirmed this exact behaviour is on staging/production as well 😬 try to type and send messages in quick succession and you will see they will shuffle and in general the requests wait for server response for a long time.

I feel like this must be something we probably already have reported somewhere but I will report in Slack just in case.

I have checked on the remaining boxes in checklist and I am approving as the issues I have found and Sobit found are on main and staging too so it is not related to this PR.

@roryabraham @cead22 Any reason why not to merge this?

@mountiny
Copy link
Contributor

mountiny commented Dec 1, 2022

The failing jobs are internal builds for testing because Rory is a mobile deployer, otherwise everything else is passing so we can merge this.

@mountiny
Copy link
Contributor

mountiny commented Dec 1, 2022

@cead22
Copy link
Contributor

cead22 commented Dec 1, 2022

The failing jobs are internal builds for testing because Rory is a mobile deployer, otherwise everything else is passing so we can merge this.

Discussed with @AndrewGable to understand this better, and I agree

@cead22 cead22 merged commit 383ce45 into main Dec 1, 2022
@cead22 cead22 deleted the Rory-SortReportActionsByCreated branch December 1, 2022 17:50
@melvin-bot melvin-bot bot added the Emergency label Dec 1, 2022
@melvin-bot
Copy link

melvin-bot bot commented Dec 1, 2022

@cead22 looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@cead22
Copy link
Contributor

cead22 commented Dec 1, 2022

As stated above, the builds that are failing are because of a bug that we're currently working to fix

@cead22 cead22 removed the Emergency label Dec 1, 2022
@cead22
Copy link
Contributor

cead22 commented Dec 1, 2022

The reviewer checklist was completed, and the checklist checks passed when re-run
image
image
image

@OSBotify
Copy link
Contributor

OSBotify commented Dec 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 Dec 2, 2022

🚀 Deployed to staging by @cead22 in version: 1.2.36-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Dec 8, 2022

🚀 Deployed to production by @francoisl in version: 1.2.36-4 🚀

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

@sobitneupane
Copy link
Contributor

I am C+ in this PR. Can anyone please help me with the payment.

cc: @mountiny @cead22

@mountiny
Copy link
Contributor

Created issue here @sobitneupane #13814

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