@@ -62,7 +62,6 @@ import * as User from '@userActions/User';
62
62
import CONST from '@src/CONST' ;
63
63
import ONYXKEYS from '@src/ONYXKEYS' ;
64
64
import ROUTES from '@src/ROUTES' ;
65
- import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
66
65
import AnimatedEmptyStateBackground from './AnimatedEmptyStateBackground' ;
67
66
import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu' ;
68
67
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu' ;
@@ -78,6 +77,7 @@ import ReportActionItemSingle from './ReportActionItemSingle';
78
77
import ReportActionItemThread from './ReportActionItemThread' ;
79
78
import reportActionPropTypes from './reportActionPropTypes' ;
80
79
import ReportAttachmentsContext from './ReportAttachmentsContext' ;
80
+ import transactionPropTypes from '@components/transactionPropTypes' ;
81
81
82
82
const propTypes = {
83
83
...windowDimensionsPropTypes ,
@@ -129,6 +129,9 @@ const propTypes = {
129
129
/** All the report actions belonging to the current report */
130
130
reportActions : PropTypes . objectOf ( PropTypes . shape ( reportActionPropTypes ) ) ,
131
131
132
+ /** All the transactions shared wit hthe user */
133
+ transactions : PropTypes . objectOf ( PropTypes . shape ( transactionPropTypes ) ) ,
134
+
132
135
/** Callback to be called on onPress */
133
136
onPress : PropTypes . func ,
134
137
} ;
@@ -144,6 +147,7 @@ const defaultProps = {
144
147
userWallet : { } ,
145
148
parentReportActions : { } ,
146
149
reportActions : { } ,
150
+ transactions : { } ,
147
151
onPress : undefined ,
148
152
} ;
149
153
@@ -167,13 +171,20 @@ function ReportActionItem(props) {
167
171
const originalReport = props . report . reportID === originalReportID ? props . report : ReportUtils . getReport ( originalReportID ) ;
168
172
const isReportActionLinked = props . linkedReportActionID && props . action . reportActionID && props . linkedReportActionID === props . action . reportActionID ;
169
173
const transactionThreadReportID = ReportActionsUtils . getOneTransactionThreadReportID ( props . reportActions ) ;
174
+ let transaction = { } ;
170
175
const transactionThreadReport = useMemo ( ( ) => {
171
176
if ( transactionThreadReportID === '0' ) {
172
177
return { } ;
173
178
}
174
- return props . reports [ `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID } ` ] ?? { } ;
175
- } , [ props . reports , transactionThreadReportID ] ) ;
179
+ const report = props . reports [ `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID } ` ] ?? { } ;
180
+
181
+ // Get the transaction associated with the report
182
+ const transactionID = props . reportActions ?. [ report . parentReportActionID ?? '' ] ?. originalMessage ?. IOUTransactionID ?? 0 ;
183
+ transaction = props . transactions [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ] ;
184
+ return report ;
185
+ } , [ props . reports , transactionThreadReportID , props . reportActions , props . transactions ] ) ;
176
186
187
+ const transactionCurrency = ! _ . isEmpty ( transaction ) ? ( transaction . modifiedCurrency ?? transaction . currency ) : props . report . currency ;
177
188
const reportScrollManager = useReportScrollManager ( ) ;
178
189
179
190
const highlightedBackgroundColorIfNeeded = useMemo (
@@ -707,9 +718,9 @@ function ReportActionItem(props) {
707
718
if ( ReportUtils . isExpenseReport ( props . report ) || ReportUtils . isIOUReport ( props . report ) ) {
708
719
return (
709
720
< OfflineWithFeedback pendingAction = { props . action . pendingAction } >
710
- { transactionThreadReport && ! isEmptyObject ( transactionThreadReport ) ? (
721
+ { transactionThreadReport && ! _ . isEmpty ( transactionThreadReport ) ? (
711
722
< >
712
- { transactionThreadReport . currency !== props . report . currency && (
723
+ { transactionCurrency !== props . report . currency && (
713
724
< MoneyReportView
714
725
report = { props . report }
715
726
policy = { props . policy }
@@ -721,7 +732,7 @@ function ReportActionItem(props) {
721
732
< MoneyRequestView
722
733
report = { transactionThreadReport }
723
734
shouldShowHorizontalRule = { ! props . shouldHideThreadDividerLine }
724
- shouldShowAnimatedBackground = { transactionThreadReport . currency === props . report . currency }
735
+ shouldShowAnimatedBackground = { transactionCurrency === props . report . currency }
725
736
/>
726
737
</ ShowContextMenuContext . Provider >
727
738
</ >
@@ -921,6 +932,9 @@ export default compose(
921
932
key : ( { report} ) => `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ report . reportID || 0 } ` ,
922
933
canEvict : false ,
923
934
} ,
935
+ transactions : {
936
+ key : ONYXKEYS . COLLECTION . TRANSACTION ,
937
+ } ,
924
938
} ) ,
925
939
) (
926
940
memo ( ReportActionItem , ( prevProps , nextProps ) => {
@@ -958,7 +972,8 @@ export default compose(
958
972
_ . isEqual ( prevProps . report . reportFields , nextProps . report . reportFields ) &&
959
973
_ . isEqual ( prevProps . policy , nextProps . policy ) &&
960
974
_ . isEqual ( prevParentReportAction , nextParentReportAction ) &&
961
- _ . isEqual ( prevProps . reportActions , nextProps . reportActions )
975
+ _ . isEqual ( prevProps . reportActions , nextProps . reportActions ) &&
976
+ _ . isEqual ( prevProps . transactions , nextProps . transactions )
962
977
) ;
963
978
} ) ,
964
979
) ;
0 commit comments