From 1718ce5663eb469491bf9445ff843cc2154b0cb1 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 9 Nov 2022 10:53:15 -0800 Subject: [PATCH 1/2] Swap out mostRecentIOUReportSequenceNumber for mostRecentIOUReportActionID --- src/libs/ReportActionsUtils.js | 9 ++++----- src/pages/home/report/ReportActionsList.js | 8 ++++---- src/pages/home/report/ReportActionsView.js | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index 6616d03511e8..ae87ff5d7ff3 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -57,12 +57,11 @@ function getSortedReportActions(reportActions) { * @param {Array} reportActions * @returns {Number} */ -function getMostRecentIOUReportSequenceNumber(reportActions) { +function getMostRecentIOUReportActionID(reportActions) { return _.chain(reportActions) - .sortBy('sequenceNumber') - .filter(action => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) + .where({actionName: CONST.REPORT.ACTIONS.TYPE.IOU}) .max(action => action.sequenceNumber) - .value().sequenceNumber; + .value().reportActionID; } /** @@ -151,7 +150,7 @@ export { getOptimisticLastReadSequenceNumberForDeletedAction, getLastVisibleMessageText, getSortedReportActions, - getMostRecentIOUReportSequenceNumber, + getMostRecentIOUReportActionID, isDeletedAction, isConsecutiveActionMadeByPreviousActor, }; diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 2aa64fca9dfe..ede5ba8afdd4 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -38,8 +38,8 @@ const propTypes = { action: PropTypes.shape(reportActionPropTypes), })).isRequired, - /** The sequence number of the most recent IOU report connected with the shown report */ - mostRecentIOUReportSequenceNumber: PropTypes.number, + /** The ID of the most recent IOU report action connected with the shown report */ + mostRecentIOUReportActionID: PropTypes.number, /** Are we loading more report actions? */ isLoadingMoreReportActions: PropTypes.bool, @@ -59,7 +59,7 @@ const propTypes = { const defaultProps = { personalDetails: {}, - mostRecentIOUReportSequenceNumber: undefined, + mostRecentIOUReportActionID: undefined, isLoadingMoreReportActions: false, }; @@ -139,7 +139,7 @@ class ReportActionsList extends React.Component { action={item.action} displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(this.props.sortedReportActions, index)} shouldDisplayNewIndicator={shouldDisplayNewIndicator} - isMostRecentIOUReportAction={item.action.sequenceNumber === this.props.mostRecentIOUReportSequenceNumber} + isMostRecentIOUReportAction={item.action.reportActionID === this.props.mostRecentIOUReportActionID} hasOutstandingIOU={this.props.report.hasOutstandingIOU} index={index} /> diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index e99a0ed70e0f..722dbb840b7f 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -79,7 +79,7 @@ class ReportActionsView extends React.Component { this.currentScrollOffset = 0; this.sortedReportActions = ReportActionsUtils.getSortedReportActions(props.reportActions); - this.mostRecentIOUReportSequenceNumber = ReportActionsUtils.getMostRecentIOUReportSequenceNumber(props.reportActions); + this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOUReportActionID(props.reportActions); this.trackScroll = this.trackScroll.bind(this); this.toggleFloatingMessageCounter = this.toggleFloatingMessageCounter.bind(this); this.loadMoreChats = this.loadMoreChats.bind(this); @@ -142,7 +142,7 @@ class ReportActionsView extends React.Component { shouldComponentUpdate(nextProps, nextState) { if (!_.isEqual(nextProps.reportActions, this.props.reportActions)) { this.sortedReportActions = ReportActionsUtils.getSortedReportActions(nextProps.reportActions); - this.mostRecentIOUReportSequenceNumber = ReportActionsUtils.getMostRecentIOUReportSequenceNumber(nextProps.reportActions); + this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOUReportActionID(nextProps.reportActions); return true; } @@ -367,7 +367,7 @@ class ReportActionsView extends React.Component { onScroll={this.trackScroll} onLayout={this.recordTimeToMeasureItemLayout} sortedReportActions={this.sortedReportActions} - mostRecentIOUReportSequenceNumber={this.mostRecentIOUReportSequenceNumber} + mostRecentIOUReportActionID={this.mostRecentIOUReportActionID} isLoadingMoreReportActions={this.props.report.isLoadingMoreReportActions} loadMoreChats={this.loadMoreChats} newMarkerSequenceNumber={this.state.newMarkerSequenceNumber} From 7eab917d34c4574fa2384cf45cb15165e1189499 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 9 Nov 2022 11:46:50 -0800 Subject: [PATCH 2/2] Fix reportActionID prop type --- src/libs/ReportActionsUtils.js | 2 +- src/pages/home/report/ReportActionsList.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index ae87ff5d7ff3..ae04dc86c494 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -55,7 +55,7 @@ function getSortedReportActions(reportActions) { * Finds most recent IOU report action number. * * @param {Array} reportActions - * @returns {Number} + * @returns {String} */ function getMostRecentIOUReportActionID(reportActions) { return _.chain(reportActions) diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index ede5ba8afdd4..7dfa83eb2358 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -39,7 +39,7 @@ const propTypes = { })).isRequired, /** The ID of the most recent IOU report action connected with the shown report */ - mostRecentIOUReportActionID: PropTypes.number, + mostRecentIOUReportActionID: PropTypes.string, /** Are we loading more report actions? */ isLoadingMoreReportActions: PropTypes.bool, @@ -59,7 +59,7 @@ const propTypes = { const defaultProps = { personalDetails: {}, - mostRecentIOUReportActionID: undefined, + mostRecentIOUReportActionID: '', isLoadingMoreReportActions: false, };