-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48522 from nkdengineer/fix/48416
fix: Use new ResolveDuplicates when approver is resolving duplicates
- Loading branch information
Showing
8 changed files
with
201 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
36 changes: 5 additions & 31 deletions
36
src/components/ReportActionItem/MoneyRequestPreview/index.tsx
This file contains 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,44 +1,18 @@ | ||
import lodashIsEmpty from 'lodash/isEmpty'; | ||
import React from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import MoneyRequestPreviewContent from './MoneyRequestPreviewContent'; | ||
import type {MoneyRequestPreviewOnyxProps, MoneyRequestPreviewProps} from './types'; | ||
import type {MoneyRequestPreviewProps} from './types'; | ||
|
||
function MoneyRequestPreview(props: MoneyRequestPreviewProps) { | ||
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${props.iouReportID || '-1'}`); | ||
// We should not render the component if there is no iouReport and it's not a split or track expense. | ||
// Moved outside of the component scope to allow for easier use of hooks in the main component. | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return lodashIsEmpty(props.iouReport) && !(props.isBillSplit || props.isTrackExpense) ? null : <MoneyRequestPreviewContent {...props} />; | ||
return lodashIsEmpty(iouReport) && !(props.isBillSplit || props.isTrackExpense) ? null : <MoneyRequestPreviewContent {...props} />; | ||
} | ||
|
||
MoneyRequestPreview.displayName = 'MoneyRequestPreview'; | ||
|
||
export default withOnyx<MoneyRequestPreviewProps, MoneyRequestPreviewOnyxProps>({ | ||
personalDetails: { | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
}, | ||
chatReport: { | ||
key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, | ||
}, | ||
iouReport: { | ||
key: ({iouReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`, | ||
}, | ||
session: { | ||
key: ONYXKEYS.SESSION, | ||
}, | ||
transaction: { | ||
key: ({action}) => { | ||
const isMoneyRequestAction = ReportActionsUtils.isMoneyRequestAction(action); | ||
const transactionID = isMoneyRequestAction ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : 0; | ||
return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; | ||
}, | ||
}, | ||
walletTerms: { | ||
key: ONYXKEYS.WALLET_TERMS, | ||
}, | ||
transactionViolations: { | ||
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, | ||
}, | ||
})(MoneyRequestPreview); | ||
export default MoneyRequestPreview; |
This file contains 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 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,24 @@ | ||
type ResolveDuplicatesParams = { | ||
/** The ID of the transaction that we want to keep */ | ||
transactionID: string; | ||
|
||
/** The list of other duplicated transactions */ | ||
transactionIDList: string[]; | ||
created: string; | ||
merchant: string; | ||
amount: number; | ||
currency: string; | ||
category: string; | ||
comment: string; | ||
billable: boolean; | ||
reimbursable: boolean; | ||
tag: string; | ||
|
||
/** The reportActionID of the dismissed violation action in the kept transaction thread report */ | ||
dismissedViolationReportActionID: string; | ||
|
||
/** The ID list of the hold report actions corresponding to the transactionIDList */ | ||
reportActionIDList: string[]; | ||
}; | ||
|
||
export default ResolveDuplicatesParams; |
This file contains 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 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 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.