Fix useTransactionViolations returning stale violations data#63722
Fix useTransactionViolations returning stale violations data#63722
Conversation
|
@shubham1206agra 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] |
@mollfpr Can you link these examples here? |
|
@shubham1206agra I have reverted the first changes and only change to use custom |
Screen.Recording.2025-06-19.at.6.08.21.PM.mov@mollfpr The holding and unholding of expenses seems to be super slow for some reason. It is making 2 Search request here. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2025-06-19.at.8.11.03.PM.movAndroid: mWeb ChromeScreen.Recording.2025-06-19.at.6.46.24.PM.moviOS: HybridAppScreen.Recording.2025-06-19.at.7.36.10.PM.moviOS: mWeb SafariScreen.Recording.2025-06-19.at.6.42.34.PM.movMacOS: Chrome / SafariScreen.Recording.2025-06-19.at.6.08.21.PM.movMacOS: DesktopScreen.Recording.2025-06-19.at.6.54.23.PM.mov |
| const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`); | ||
| const [transactionViolations = []] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`); | ||
| const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { | ||
| canBeMissing: true, | ||
| }); | ||
| const [transactionViolations = []] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, { | ||
| canBeMissing: true, | ||
| }); |
There was a problem hiding this comment.
Im a little confused, it looks like the PR description doesn't seem to line up with the changes? It looks like we are just adding the canBeMissing but why?
There was a problem hiding this comment.
@rlinoz It was not updated, but the actual update is https://expensify.slack.com/archives/C05LX9D6E07/p1749519744150989. TLDR - We are now using a custom useOnyx hook to resolve this issue.
There was a problem hiding this comment.
aaah we changed the import and are using a different useOnyx, got it. Thanks!
| const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`); | ||
| const [transactionViolations = []] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`); | ||
| const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { | ||
| canBeMissing: true, | ||
| }); | ||
| const [transactionViolations = []] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, { | ||
| canBeMissing: true, | ||
| }); |
There was a problem hiding this comment.
aaah we changed the import and are using a different useOnyx, got it. Thanks!
|
✋ 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/rlinoz in version: 9.1.70-0 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.70-7 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.70-7 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.70-7 🚀
|
1 similar comment
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.70-7 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 9.1.70-7 🚀
|

Explanation of Change
We are using
useOnyxwith the transactionID key to get the violations data. Apparently, this won't guarantee the return of the latest data. So instead of using a key to get Onyx data, we use the collection to get the violations. We have a similar approach on the other components, such asMoneyReportHeaderorLHNOptionsList.Fixed Issues
$ #62541
PROPOSAL:
Tests
Same as the QA steps.
Offline tests
N/A
QA Steps
Prerequisites:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)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
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.Jun.9.2025.mp4
MacOS: Desktop