Repository navigation
Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.REPORTS from src/libs/actions/IOU/Transaction.ts #93734
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
Merged
mjasikowski
merged 35 commits into
Expensify:main
from
software-mansion-labs:Guccio163/onyx-connect/transaction/report
Aug 11, 2026
Merged
Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.REPORTS from src/libs/actions/IOU/Transaction.ts #93734
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
79acb6e
extract reports out of changeTransactionsReport, yet to fix useUndele…
Guccio163 3925ddc
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 e5a7cc1
fix tests
Guccio163 e22feef
include codex suggestion
Guccio163 cfb2c23
remove selector from useChangeTransactionsReportReports
Guccio163 770e146
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 7bced5f
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 c70ce5a
fix tests
Guccio163 295a314
patch changeTransactionsReport
Guccio163 9190653
Merge branch 'main' into Guccio163/onyx-connect/transaction/report
Guccio163 39d21eb
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 d391988
format new hook with fmt
Guccio163 c61712e
use reports argument in new allReport usages
Guccio163 b2e64af
Narrow report subscription with a useOnyx selector and drop redundant…
Guccio163 34b2e00
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 a9772ef
fix test
Guccio163 566997a
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 e90c811
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 3ef45f8
fix test ts
Guccio163 6c93ea3
fix tests/actions/ReportTest.ts fail
Guccio163 d03de9a
Fix tests broken by react-native-onyx API update
Guccio163 34b48d2
optimistic reports logic fix
Guccio163 e552919
Include transactionCount/unheldNonReimbursableTotal in reportsForCall…
Guccio163 efad694
Document what useChangeTransactionsReportReports includes in its result
Guccio163 f14710a
Add unit tests for useChangeTransactionsReportReports
Guccio163 8a87669
Fix stale policyID key in old transaction thread rollback
Guccio163 0d54bc5
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 fdc510c
Fix TransactionTest.ts after merging main
Guccio163 18eb532
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 6f7e3e0
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 cd3b7a0
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 6693b04
Remove orphaned jsonQuery/hash tests from TransactionTest.ts
Guccio163 2a4d4ad
Simplify useChangeTransactionsReportReports and cover UNREPORTED_REPO…
Guccio163 78b5d91
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 cbd91c3
Seed transactionCount/unheldNonReimbursableTotal on optimistic report…
Guccio163 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import {getIOUActionForReportID} from '@libs/ReportActionsUtils'; | ||
| import {findSelfDMReportID} from '@libs/ReportUtils'; | ||
| import {isDeletedTransaction} from '@libs/TransactionUtils'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Report, Transaction} from '@src/types/onyx'; | ||
|
|
||
| import type {OnyxCollection} from 'react-native-onyx'; | ||
|
|
||
| import useOnyx from './useOnyx'; | ||
|
|
||
| /** | ||
| * Resolve the REPORT subset that `changeTransactionsReport` looks up — keyed like the full collection so the action | ||
| * can do `reports?.[\`${KEY}${id}\`]`. Includes: | ||
| * - the unreported-report sentinel, looked up for transactions moving out of personal space | ||
| * - the self-DM report, if one exists | ||
| * - the destination report (`newReportID`) | ||
| * - each transaction's current report | ||
| * - for non-deleted transactions, the old IOU action's transaction-thread report (`childReportID`) | ||
| */ | ||
| function useChangeTransactionsReportReports(transactions: Transaction[], newReportID: string | undefined): OnyxCollection<Report> { | ||
| const ids = new Set<string>(); | ||
| ids.add(CONST.REPORT.UNREPORTED_REPORT_ID); | ||
| const selfDMReportID = findSelfDMReportID(); | ||
| if (selfDMReportID) { | ||
| ids.add(selfDMReportID); | ||
| } | ||
| if (newReportID) { | ||
| ids.add(newReportID); | ||
| } | ||
| for (const transaction of transactions) { | ||
| if (transaction.reportID) { | ||
| ids.add(transaction.reportID); | ||
| } | ||
| if (isDeletedTransaction(transaction)) { | ||
| continue; | ||
| } | ||
| const isUnreportedExpense = !transaction.reportID || transaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID; | ||
| const source = isUnreportedExpense ? selfDMReportID : transaction.reportID; | ||
| if (!source) { | ||
| continue; | ||
| } | ||
| const iouAction = getIOUActionForReportID(source, transaction.transactionID); | ||
| if (iouAction?.childReportID) { | ||
| ids.add(iouAction.childReportID); | ||
| } | ||
| } | ||
| const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { | ||
| selector: (allReports) => { | ||
|
Guccio163 marked this conversation as resolved.
Resolved
|
||
| const result: Record<string, Report | undefined> = {}; | ||
| for (const id of ids) { | ||
| const key = `${ONYXKEYS.COLLECTION.REPORT}${id}` as const; | ||
| const report = allReports?.[key]; | ||
| if (report) { | ||
| result[key] = report; | ||
| } | ||
| } | ||
| return result as OnyxCollection<Report>; | ||
| }, | ||
| }); | ||
| return reports; | ||
| } | ||
|
|
||
| export default useChangeTransactionsReportReports; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.