[Part 1]Remove Onyx.connect() for the key: ONYXKEYS.SESSION in src/libs/actions/Report.ts#78751
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@parasharrajat 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] |
|
I've updated |
I've updated |
| const [originalTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transaction?.comment?.originalTransactionID)}`, {canBeMissing: true}); | ||
| const {isExpenseSplit} = getOriginalTransactionWithSplitInfo(transaction, originalTransaction); | ||
| const isSplitAvailable = moneyRequestReport && transaction && isSplitAction(moneyRequestReport, [transaction], originalTransaction, policy); | ||
| const isSplitAvailable = moneyRequestReport && transaction && isSplitAction(moneyRequestReport, [transaction], originalTransaction, currentUserPersonalDetails.email ?? '', policy); |
There was a problem hiding this comment.
This component already has const currentUserEmailParam = currentUserPersonalDetails.login ?? '';. Would you please:
- Rename that const to
currentUserLogin - Update the existing references to the new constant name
- Use that same constant here for
isSplitAction()
src/components/Search/index.tsx
Outdated
| isHeld: isOnHold(transactionItem), | ||
| canUnhold: canUnholdRequest, | ||
| canSplit: isSplitAction(transactionItem.report, [itemTransaction], originalItemTransaction, transactionItem.policy), | ||
| canSplit: isSplitAction(transactionItem.report, [itemTransaction], originalItemTransaction, email ?? '', transactionItem.policy), |
There was a problem hiding this comment.
NAB: If email is aliased to be currentUserLogin, I think that would make it more consistent everywhere. Better yet, I think this component should use const {accountID, login} = useCurrentUserPersonalDetails(); (instead of email)
src/components/MoneyReportHeader.tsx
Outdated
| return; | ||
| } | ||
| downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate); | ||
| downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, email ?? ''); |
There was a problem hiding this comment.
This component already has currentUserLogin so reference that instead.
| const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(selectedTransactionIDs); | ||
| const isReportArchived = useReportIsArchived(report?.reportID); | ||
| const {deleteTransactions} = useDeleteTransactions({report, reportActions, policy}); | ||
| const {email} = useCurrentUserPersonalDetails(); |
src/hooks/useTodos.ts
Outdated
| reportsToPay.push(report); | ||
| } | ||
| if (isExportAction(report, policy, reportActions)) { | ||
| if (isExportAction(report, email, policy, reportActions)) { |
|
|
||
| function getSecondaryReportActions({ | ||
| currentUserEmail, | ||
| currentUserEmail: currentUserLogin, |
There was a problem hiding this comment.
Rename the function parameter to currentUserLogin rather than keeping it currentUserEmail (this is the only place that getSecondaryReportActions() is called, so it's an easy change)
| const currentPolicy = Object.keys(policy?.employeeList ?? {}).length | ||
| ? policy | ||
| : currentSearchResults?.data?.[`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(currentReport?.policyID)}`]; | ||
| const {email} = useCurrentUserPersonalDetails(); |
There was a problem hiding this comment.
| const {email} = useCurrentUserPersonalDetails(); | |
| const {login} = useCurrentUserPersonalDetails(); |
| const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${currentReport?.policyID}`, {canBeMissing: false}); | ||
|
|
||
| const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${currentReport?.policyID}`, {canBeMissing: false}); | ||
| const {email} = useCurrentUserPersonalDetails(); |
There was a problem hiding this comment.
| const {email} = useCurrentUserPersonalDetails(); | |
| const {login} = useCurrentUserPersonalDetails(); |
| const searchHash = searchContext?.currentSearchHash ?? CONST.DEFAULT_NUMBER_ID; | ||
| const [currentSearchResults] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, {canBeMissing: true}); | ||
| const allTransactions = useAllTransactions(); | ||
| const currentUserPersonalDetails = useCurrentUserPersonalDetails(); |
There was a problem hiding this comment.
Can this be destructured to use {login} like the other components?
There was a problem hiding this comment.
The function updateSplitTransactionsFromSplitExpensesFlow requires the full currentUserPersonalDetails object.
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const personalDetailsList = usePersonalDetails(); | ||
| const {email} = useCurrentUserPersonalDetails(); |
There was a problem hiding this comment.
| const {email} = useCurrentUserPersonalDetails(); | |
| const {login} = useCurrentUserPersonalDetails(); |
|
@tgolen |
|
Yeah, we could, but I don't think it would hurt to start updating it in a few places that we come across it. |
|
|
|
@tgolen I've updated |
|
Dropping off here, Tim has it under control 👋 |
|
@linhvovan29546 this picked up quite a few conflicts. Could you please fix them and then I'll take another look at it. |
|
@tgolen I'v resolved conflict |
tgolen
left a comment
There was a problem hiding this comment.
Great, thanks for helping to clean this up a little bit!
|
✋ 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/tgolen in version: 9.3.0-0 🚀
|
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.3.0-8 🚀
|
Explanation of Change
This PR deprecates
currentUserEmailas part 1 of removingOnyx.connect() for the ONYXKEYS.SESSION key in src/libs/actions/Report.ts.currentUserEmailwill be removed completely after the migration is finished.Fixed Issues
$ #73648
PROPOSAL: N/A
Tests
Test 1:
Test 2:
Test 3:
Offline tests
Same as tests
QA Steps
Same as tests
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))npm run compress-svg)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
Screen.Recording.2026-01-02.at.11.56.55.mov
Android: mWeb Chrome
Screen.Recording.2026-01-02.at.11.54.42.mov
iOS: Native
Screen.Recording.2026-01-02.at.11.52.32.mov
iOS: mWeb Safari
Screen.Recording.2026-01-02.at.11.43.25.mov
MacOS: Chrome / Safari
Screen.Recording.2026-01-02.at.11.23.03.mov
Screen.Recording.2026-01-02.at.11.32.57.mov
Screen.Recording.2026-01-02.at.11.40.24.mov