perf: recalculate getOrderedReportIDs only on web and desktop#46276
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: NativeuseReportIDsAndroid.mp4Android: mWeb ChromeuseReportIDsAndroidmWeb.mp4iOS: mWeb SafariuseReportIDsiOSmWeb.mp4MacOS: Chrome / SafariuseReportIDsChrome.mp4useReportIDsChrome1.mp4MacOS: DesktopuseReportIDsDesktop.mp4 |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #46291 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
dangrous
left a comment
There was a problem hiding this comment.
Seems worth a shot! I have two quick questions but approved:
- Why do we need to also run this if
orderedReportIDsis empty? shouldUseNarrowLayoutwould also be true if the web / desktop windows are narrow enough (I think) - do we need to worry about the case where someone hits this code and then makes the window bigger? Seems relatively uncommon but possible
@dangrous Good point. However, I think this won't be an issue. The reason is that we are mostly trying to improve the performance on mobile devices, so it means mobile web or mobile app. The layout there only shows one screen or one part of UI at a time. If some user narrows the layout on desktop this |
|
Okay cool, yeah I think this is worth merging, and will do so (after writing this comment). I do want to call out for the future, after the discussion above, the edge case - which is not worth blocking at the moment - where:
So if we can figure out a way to fix that as a follow up maybe? |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
I see the expense showing up on LHN here on expanding the window. enlargeScreen1.mp4enlargeScreen2.mp4When we expand the window to a size above mobile size |
|
Backlinking to #45528 |
|
ooh okay i misunderstood the flow then - if that works then I think we're good! |
|
🚀 Deployed to staging by https://github.com/dangrous in version: 9.0.15-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.15-9 🚀
|

Details
This change limits re-calculating
getOrderedReportIDson mobile. Which means that this will only be called on web and desktop. Consider a case, where we open a report with expenses, when we click on a expense a new LHN item is added in the LHN list and we are navigated to that new item, when we navigate back OR away from that new item it is then gone. Whereas on mobile, we are just navigated to the next screen with expense details, so there's no LHN being visible, so there seems no point in re-calculating this expensive function on mobile.Before:
After:
So if we average out before it is 118.28ms and after is 44.8ms, so we save around 60% for the case described above.
Fixed Issues
$ #46291
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov