Skip to content

Commit

Permalink
Merge pull request #15677 from Expensify/jules-fixSendMoneyIOUPreviewBug
Browse files Browse the repository at this point in the history
Fix bug where IOUPreview is not show for requests following a send money action
  • Loading branch information
Julesssss authored Mar 8, 2023
2 parents a34c4a7 + b1dd65d commit 47e7c3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,19 @@ function getSortedReportActions(reportActions, shouldSortInDescendingOrder = fal
}

/**
* Finds most recent IOU report action number.
* Finds most recent IOU request action ID.
*
* @param {Array} reportActions
* @returns {String}
*/
function getMostRecentIOUReportActionID(reportActions) {
const iouActions = _.where(reportActions, {actionName: CONST.REPORT.ACTIONS.TYPE.IOU});
if (_.isEmpty(iouActions)) {
function getMostRecentIOURequestActionID(reportActions) {
const iouRequestActions = _.filter(reportActions, action => lodashGet(action, 'originalMessage.type') === CONST.IOU.REPORT_ACTION_TYPE.CREATE);

if (_.isEmpty(iouRequestActions)) {
return null;
}

const sortedReportActions = getSortedReportActions(iouActions);
const sortedReportActions = getSortedReportActions(iouRequestActions);
return _.last(sortedReportActions).reportActionID;
}

Expand Down Expand Up @@ -226,7 +227,7 @@ export {
getSortedReportActions,
getLastVisibleAction,
getLastVisibleMessageText,
getMostRecentIOUReportActionID,
getMostRecentIOURequestActionID,
isDeletedAction,
isConsecutiveActionMadeByPreviousActor,
getSortedReportActionsForDisplay,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ReportActionsView extends React.Component {
};

this.currentScrollOffset = 0;
this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOUReportActionID(props.reportActions);
this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions);
this.trackScroll = this.trackScroll.bind(this);
this.toggleFloatingMessageCounter = this.toggleFloatingMessageCounter.bind(this);
this.loadMoreChats = this.loadMoreChats.bind(this);
Expand Down Expand Up @@ -129,7 +129,7 @@ class ReportActionsView extends React.Component {

shouldComponentUpdate(nextProps, nextState) {
if (!_.isEqual(nextProps.reportActions, this.props.reportActions)) {
this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOUReportActionID(nextProps.reportActions);
this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOURequestActionID(nextProps.reportActions);
return true;
}

Expand Down

0 comments on commit 47e7c3d

Please sign in to comment.