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

Fixed LHN Ordering #35907

Merged
merged 26 commits into from
Mar 4, 2024
Merged

Fixed LHN Ordering #35907

merged 26 commits into from
Mar 4, 2024

Conversation

shubham1206agra
Copy link
Contributor

@shubham1206agra shubham1206agra commented Feb 6, 2024

Details

Fixed Issues

$ #33029
PROPOSAL: #33029 (comment)

Tests

  1. Open app
  2. Open report
  3. Write a message
  4. See if LHN ordering is correct (chat with the draft is ordered correctly)
  5. Change the language and repeat the steps
  6. Verify that the ordering matches too (use pinned, drafts, archived, RBR / GBR)
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 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 form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label 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.

Screenshots/Videos

Android: Native
Screen.Recording.2024-02-28.at.1.52.56.PM.mov
Android: mWeb Chrome
Screen.Recording.2024-02-28.at.12.24.46.PM.mov
iOS: Native
Screen.Recording.2024-02-28.at.1.37.35.PM.mov
iOS: mWeb Safari
Screen.Recording.2024-02-28.at.12.09.16.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2024-02-28.at.11.38.22.AM.mp4
MacOS: Desktop
Screen.Recording.2024-02-28.at.12.49.06.PM.mov

@shubham1206agra shubham1206agra mentioned this pull request Feb 6, 2024
50 tasks
@shubham1206agra
Copy link
Contributor Author

We may need to create a perf test to know the actual performance hit.

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.

@shubham1206agra it seems like we're not sorting the reports here and also not taking into account the performance suggestions we raised during discussion. Are you still working on this POC?

@shubham1206agra
Copy link
Contributor Author

@luacmartins We are sorting the reports already. I need to write a test here to measure performance. I will write the suggestion in a commit later.

@luacmartins
Copy link
Contributor

@fedirjh were you able to take a look at this PR?

@fedirjh
Copy link
Contributor

fedirjh commented Feb 9, 2024

@shubham1206agra It seems that this PR is still in progress? Could you please include the performance improvements discussed in the linked issue? Specifically this one #33029 (comment)

@youssef-lr
Copy link
Contributor

We are sorting the reports already.

Yes but not alphanumerically, channels room names can include # for example and that messes up the order. You mentioned in your proposal this which I think should be included in the PR:

For this we need to use the replace replace(/[^0-9a-z]/gi, '') to remove non-alphanumeric characters.

Let's also include this optimisation in SidebarLinksData. I'm not sure if we need to write a test for this though, shouldn't reassure fail if this is affects performance badly?

@shubham1206agra
Copy link
Contributor Author

shubham1206agra commented Feb 19, 2024

@fedirjh Can you test this PR on HT account and see if anything is out of order?
cc @youssef-lr

src/pages/home/sidebar/SidebarLinksData.js Outdated Show resolved Hide resolved
src/pages/home/sidebar/SidebarLinksData.js Outdated Show resolved Hide resolved
tests/perf-test/SidebarUtils.perf-test.ts Show resolved Hide resolved
src/libs/SidebarUtils.ts Show resolved Hide resolved
@shubham1206agra
Copy link
Contributor Author

shubham1206agra commented Feb 19, 2024

@fedirjh I think we are checking error on too many reports. Let me redo this in another way, and see if there are still performance regressions.

@fedirjh
Copy link
Contributor

fedirjh commented Feb 19, 2024

I think we are checking error on too many reports.

What do you mean ?

Let me redo this in another way, and see if there are still performance regressions.

@shubham1206agra Do we have any performance regression?

@shubham1206agra
Copy link
Contributor Author

  • [ReportScreen] should press of the report item [render]: 133.3 ms → 205.1 ms (+71.8 ms, +53.9%) 🔴🔴 | 4 → 4
  • [ReportScreen] should render ReportScreen with composer interactions [render]: 148.7 ms → 219.5 ms (+70.8 ms, +47.6%) 🔴🔴 | 6 → 6

@fedirjh
Copy link
Contributor

fedirjh commented Feb 19, 2024

@shubham1206agra Could you please also update the test ? I don't think we are getting the correct results for this test :

  • [SidebarUtils] getOrderedReportIDs on 1k reports

personalDetails,
preferredLocale: preferredLocale ?? CONST.LOCALES.DEFAULT,
policy,
parentReportAction,
reportErrors,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not added to the dependencies of useMemo

Copy link
Contributor

Choose a reason for hiding this comment

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

reportErrors seems to be an object, if we add it as dependency we should memoize it also on the parent component

parent:

const reportErrors = useMemo(() => reportIDsWithErrors[reportID] ?? {}, [reportID]);

and not sure about reportIDsWithErrors
cc: @youssef-lr

(errorsMap, reportKey) => {
const report = chatReports[reportKey];
const allReportsActions = allReportActions[reportKey.replace(ONYXKEYS.COLLECTION.REPORT, ONYXKEYS.COLLECTION.REPORT_ACTIONS)];
const errors = OptionsListUtils.getAllReportErrors(report, allReportsActions) || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should pass the violations to getAllReportErrors and add them to the dependencies of the memo. If we don't, this function will not be re-triggered if a violation changes in Onyx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should re-render as transactionViolations changes, which is a dependency of memo.

Copy link
Contributor

@youssef-lr youssef-lr Feb 28, 2024

Choose a reason for hiding this comment

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

But it is not a dependency of reportIDsWithErrors here, which means we won't re-run getAllReportErrors

Copy link
Contributor

Choose a reason for hiding this comment

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

@youssef-lr I think this is not needed. We are already subscribing to the violation collection, and it should re-render whenever any of the violations are updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

While yes the page will re-render, the reportIDsWithErrors will remain unchanged, as it only listens to changes in report actions and chat reports.

Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1206agra bump, can we pass the transactions to getAllReportErrors?

Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies for the confusion, @fedirjh I disagree. Prior to the PR we weren’t pinning RBR reports, now that we’re memoized them, they are not subscribing to changes in the transaction.

Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1206agra @fedirjh what's the latest here?

Copy link
Contributor

Choose a reason for hiding this comment

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

We are awaiting @shubham1206agra to implement the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fedirjh Can you retest this now?

Copy link
Contributor

@youssef-lr youssef-lr left a comment

Choose a reason for hiding this comment

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

Let's add violations transactions to getAllReportErrors as param and memoize them.

@shubham1206agra
Copy link
Contributor Author

Screen.Recording.2024-02-28.at.11.13.31.AM.mov

@youssef-lr Please check this video.

@shubham1206agra shubham1206agra marked this pull request as ready for review February 28, 2024 06:16
@shubham1206agra shubham1206agra requested a review from a team as a code owner February 28, 2024 06:16
@melvin-bot melvin-bot bot requested review from danieldoglas and removed request for a team February 28, 2024 06:16
Copy link

melvin-bot bot commented Feb 28, 2024

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

): string[] {
const isInGSDMode = priorityMode === CONST.PRIORITY_MODE.GSD;
const isInDefaultMode = !isInGSDMode;
const allReportsDictValues = Object.values(allReports);

const reportIDsWithViolations = new Set<string>();
Copy link
Contributor

@fedirjh fedirjh Feb 28, 2024

Choose a reason for hiding this comment

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

Couldn't this be moved to SidebarLinksData.js similar to reportIDsWithErrors ? I think this will give some perf boost?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. It didn't give any.

Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@danieldoglas
Copy link
Contributor

Removing myself since I'm not part of the original issue. Not sure why pullerbear added me.

@danieldoglas danieldoglas removed their request for review February 28, 2024 11:08
@youssef-lr
Copy link
Contributor

Removing myself since I'm not part of the original issue. Not sure why pullerbear added me.

It seems like it always add an extra reviewer once PR is no longer a draft.

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. Just this open request from @youssef-lr

Copy link
Contributor

@youssef-lr youssef-lr left a comment

Choose a reason for hiding this comment

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

LGTM!

@youssef-lr youssef-lr dismissed luacmartins’s stale review March 4, 2024 13:47

Changes requested have been applied and Carlos already approved.

@youssef-lr youssef-lr merged commit a662e5c into Expensify:main Mar 4, 2024
17 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Mar 4, 2024

✋ 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 Mar 4, 2024

🚀 Deployed to staging by https://github.com/youssef-lr in version: 1.4.47-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Mar 6, 2024

🚀 Deployed to production by https://github.com/roryabraham in version: 1.4.47-10 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 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.

8 participants