fix: autoscroll when receiving a payment#57609
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-03-19.at.5.28.42.PM.movAndroid: mWeb ChromeScreen.Recording.2025-03-19.at.5.24.48.PM.moviOS: NativeScreen.Recording.2025-03-19.at.5.23.06.PM.moviOS: mWeb SafariScreen.Recording.2025-03-19.at.5.20.45.PM.movMacOS: Chrome / SafariScreen.Recording.2025-03-19.at.4.22.19.PM.movMacOS: DesktopScreen.Recording.2025-03-19.at.4.49.26.PM.mov |
|
@TMisiukiewicz I'm still able to reproduce the bug when the two sessions are active: Screen.Recording.2025-03-03.at.4.02.13.PM.mov |
|
@rayane-d yeah seems like the issue is more complicated 😨 I was able to narrow down the issue - it's most likely trying to find a transaction in |
|
Hmm I did more investigation and not sure how to approach this issue. It's because we already have a report action with report ID of IOU, but the transaction is not yet in the Onyx. So the height of the issue changes dynamically once the transaction is loaded and placeholder image is displayed. It's kinda different than the originally fixed issue because in this case we don't trigger an additional rerender through window focus. If Pusher update had a transaction update separated from the rest it would work, but I don't think it's proper solution for this issue. @rayane-d since this is a separate scenario from the originally reported, how about we move forward with the current shape of the PR to not block the fix for that? We could create a separate issue as this would be related only to web and desktop (because you cannot have the app open on mobile without focus on it). |
|
@rayane-d friendly bump ⬆️ |
|
Sorry for the delay, checking now |
|
Trying to investigate as well |
Sounds good to me 👍 |
|
Works well for the originally reported bug
|
Reported here: https://expensify.slack.com/archives/C049HHMV9SM/p1742400602202699 |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #57287 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
| ), | ||
| }); | ||
| return [report, transactions, violations]; | ||
| return [report, transactions ?? [], violations ?? {}]; |
There was a problem hiding this comment.
can we memoize the transactions ?? [] and violations ?? {} so the reference to the default values is stable when transactions or violations is undefined/null?
I'm asking for this because we have code using useMemo and passing as a dependency these values. If the [] / {} is recreated on each render, then those useMemo that watch these values won't be able to cache properly.
For example:
App/src/components/ReportActionItem/ReportPreview.tsx
Lines 166 to 176 in db79b14
There was a problem hiding this comment.
an alternative could be to define some constants outside the component for the defaults outside, so they stay as the same instance always:
const DEFAULT_TRANSACTIONS = [];
const DEFAULT_VIOLATIONS = {};
then in the component:
return [report, transactions ?? DEFAULT_TRANSACTIONS, violations ?? DEFAULT_VIOLATIONS];
There was a problem hiding this comment.
thanks @aldo-expensify , I went with defining the defaults outside, tested it and it works properly 👍
There was a problem hiding this comment.
Thanks for addressing
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/aldo-expensify in version: 9.1.17-0 🚀
|
|
This fails on the desktop for me as well. @aldo-expensify please make sure the issue doesn't get closed until we fix the desktop App. |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.1.17-1 🚀
|
|
Checking 👀 |
|
@kavimuru @cristipaval mind sharing a video? Seems to work fine for me Screen.Recording.2025-03-25.at.09.58.06.mov |
Explanation of Change
Transactions had initial value set to empty array, which was used each time user was going back to the report preview. Based on the amount of the transactions with receipts, if there are none, the
ReportActionItemImageswas not rendered. After transactions were loaded, it appeared in the report preview, but the positioning of the scroll remained the same. With removing the initial value, we persist the transactions and prevent them to be cleared when going back to the screen.Fixed Issues
$ #57287
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
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: mWeb Chrome
android-web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov