-
Notifications
You must be signed in to change notification settings - Fork 4k
Remove SearchTransaction > isFromOneTransactionReport #75484
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
luacmartins
merged 15 commits into
Expensify:main
from
s77rt:remove-SearchTransaction-isFromOneTransactionReport
Dec 1, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dcb8063
remove SearchTransaction > isFromOneTransactionReport
s77rt e08fc20
update isFromOneTransactionReport source
s77rt 7f90459
update MoneyRequestReportUtilsTest
s77rt 04f930b
fix tests
s77rt d08761a
fix spellcheck
s77rt 9208117
fix ts
s77rt 8e7aa08
merge main
s77rt 5f6f8f6
use isOneTransactionReport util
s77rt 3941cce
lint + ts
s77rt 4db40cd
Merge branch 'main' into remove-SearchTransaction-isFromOneTransactio…
s77rt ab50a51
ts
s77rt 5849d92
fix test
s77rt db06d98
Merge branch 'main' into remove-SearchTransaction-isFromOneTransactio…
s77rt dafd185
add back previous isOneTransactionReport logic as a deprecated function
s77rt ecf0415
cleanup
s77rt 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,141 @@ | ||
| import type {TransactionListItemType} from '@components/SelectionListWithSections/types'; | ||
| import {getReportIDForTransaction} from '@libs/MoneyRequestReportUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import type {Policy, Report, ReportAction} from '@src/types/onyx'; | ||
|
|
||
| const transactionItemBaseMock = { | ||
| reportID: 'report123', | ||
| transactionThreadReportID: 'thread123', | ||
| } as TransactionListItemType; | ||
| const policyBaseMock: Policy = { | ||
| id: '123456789A', | ||
| name: 'Policy', | ||
| role: 'admin', | ||
| outputCurrency: 'USD', | ||
| type: 'team', | ||
| owner: 'admin@test.com', | ||
| isPolicyExpenseChatEnabled: true, | ||
| }; | ||
|
|
||
| const reportBaseMock: Report = { | ||
| chatReportID: '1706144653204915', | ||
| created: '2024-12-21 13:05:20', | ||
| currency: 'USD', | ||
| isWaitingOnBankAccount: false, | ||
| managerID: 100, | ||
| nonReimbursableTotal: 0, | ||
| ownerAccountID: 100, | ||
| policyID: policyBaseMock.id, | ||
| reportID: '123', | ||
| reportName: 'Expense Report #123', | ||
| stateNum: 1, | ||
| statusNum: 1, | ||
| total: -5000, | ||
| type: 'expense', | ||
| unheldTotal: -5000, | ||
| transactionCount: 5, | ||
| }; | ||
|
|
||
| const reportActionBaseMock: ReportAction = { | ||
| accountID: 100, | ||
| actorAccountID: 100, | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.IOU, | ||
| created: '2024-12-21 13:05:21', | ||
| message: [{type: 'COMMENT', html: 'IOU', text: 'IOU'}], | ||
| reportActionID: '11111111', | ||
| originalMessage: { | ||
| type: CONST.IOU.REPORT_ACTION_TYPE.CREATE, | ||
| IOUTransactionID: '555', | ||
| IOUReportID: reportBaseMock.reportID, | ||
| }, | ||
| reportID: reportBaseMock.reportID, | ||
| }; | ||
|
|
||
| const transactionItemBaseMock: TransactionListItemType = { | ||
| action: 'submit', | ||
| allActions: ['submit'], | ||
| amount: -5000, | ||
| report: reportBaseMock, | ||
| policy: policyBaseMock, | ||
| reportAction: reportActionBaseMock, | ||
| holdReportAction: undefined, | ||
| canDelete: true, | ||
| cardID: undefined, | ||
| cardName: undefined, | ||
| category: '', | ||
| comment: {comment: ''}, | ||
| created: '2024-12-21', | ||
| currency: 'USD', | ||
| date: '2024-12-21', | ||
| formattedFrom: 'Admin', | ||
| formattedMerchant: 'Expense', | ||
| formattedTo: '', | ||
| formattedTotal: 5000, | ||
| from: { | ||
| accountID: 18439984, | ||
| avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', | ||
| displayName: 'Admin', | ||
| login: 'admin@test.com', | ||
| }, | ||
| hasEReceipt: false, | ||
| keyForList: '1', | ||
| merchant: 'Expense', | ||
| modifiedAmount: 0, | ||
| modifiedCreated: '', | ||
| modifiedCurrency: '', | ||
| modifiedMerchant: 'Expense', | ||
| parentTransactionID: '', | ||
| pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, | ||
| reportID: reportBaseMock.reportID, | ||
| shouldShowMerchant: true, | ||
| shouldShowYear: true, | ||
| isAmountColumnWide: false, | ||
| isTaxAmountColumnWide: false, | ||
| tag: '', | ||
| to: { | ||
| accountID: 0, | ||
| avatar: '', | ||
| displayName: undefined, | ||
| login: undefined, | ||
| }, | ||
| transactionID: '1', | ||
| transactionThreadReportID: '456', | ||
| receipt: undefined, | ||
| taxAmount: undefined, | ||
| mccGroup: undefined, | ||
| modifiedMCCGroup: undefined, | ||
| moneyRequestReportActionID: '789', | ||
| errors: undefined, | ||
| filename: undefined, | ||
| violations: [], | ||
| convertedAmount: -5000, | ||
| convertedCurrency: 'USD', | ||
| }; | ||
|
|
||
| describe('MoneyRequestReportUtils', () => { | ||
| describe('getReportIDForTransaction', () => { | ||
| it('returns transaction thread ID if its not from one transaction report', () => { | ||
| const transactionItem = {...transactionItemBaseMock}; | ||
| const transactionItem: TransactionListItemType = {...transactionItemBaseMock}; | ||
| const resultID = getReportIDForTransaction(transactionItem); | ||
|
|
||
| expect(resultID).toBe('thread123'); | ||
| expect(resultID).toBe('456'); | ||
| }); | ||
|
|
||
| it('returns transaction thread ID if its from self DM', () => { | ||
| const transactionItem = {...transactionItemBaseMock, reportID: CONST.REPORT.UNREPORTED_REPORT_ID}; | ||
| const transactionItem: TransactionListItemType = {...transactionItemBaseMock, reportID: CONST.REPORT.UNREPORTED_REPORT_ID}; | ||
| const resultID = getReportIDForTransaction(transactionItem); | ||
|
|
||
| expect(resultID).toBe('thread123'); | ||
| expect(resultID).toBe('456'); | ||
| }); | ||
|
|
||
| it('returns expense reportID if its from one transaction report', () => { | ||
| const transactionItem = {...transactionItemBaseMock, isFromOneTransactionReport: true}; | ||
| const transactionItem: TransactionListItemType = {...transactionItemBaseMock, report: {...reportBaseMock, transactionCount: 1}}; | ||
| const resultID = getReportIDForTransaction(transactionItem); | ||
|
|
||
| expect(resultID).toBe('report123'); | ||
| expect(resultID).toBe('123'); | ||
| }); | ||
|
|
||
| it('returns reportID if transaction thread ID is 0 - unreported', () => { | ||
| const transactionItem = {...transactionItemBaseMock, transactionThreadReportID: CONST.REPORT.UNREPORTED_REPORT_ID}; | ||
| const transactionItem: TransactionListItemType = {...transactionItemBaseMock, transactionThreadReportID: CONST.REPORT.UNREPORTED_REPORT_ID}; | ||
| const resultID = getReportIDForTransaction(transactionItem); | ||
|
|
||
| expect(resultID).toBe('report123'); | ||
| expect(resultID).toBe('123'); | ||
| }); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of this existing function before. Uhmm, if we touch this function, we probably need to optimistically update
transactionCounton adding/deleting/moving transactions to support offline mode.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I have added back the original function as a deprecated function and kept its use in that file. New usage should use the new function and handle the optimistic data accordingly.