diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index 6616d03511e8..ae04dc86c494 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -55,14 +55,13 @@ function getSortedReportActions(reportActions) { * Finds most recent IOU report action number. * * @param {Array} reportActions - * @returns {Number} + * @returns {String} */ -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..7dfa83eb2358 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.string, /** Are we loading more report actions? */ isLoadingMoreReportActions: PropTypes.bool, @@ -59,7 +59,7 @@ const propTypes = { const defaultProps = { personalDetails: {}, - mostRecentIOUReportSequenceNumber: undefined, + mostRecentIOUReportActionID: '', 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}