From f085f1177063419377b78d123e92e8edfe0e5425 Mon Sep 17 00:00:00 2001 From: Barun Pandey Date: Wed, 17 Mar 2021 18:21:37 +0545 Subject: [PATCH] Add comments to clarify indexOffset logic --- .../iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js | 2 +- .../iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js | 6 ++++++ src/pages/iou/steps/IOUParticipantsPage/index.js | 1 - 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js index 5eeeb51a8755..2ade0725a778 100644 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js @@ -64,7 +64,7 @@ class IOUParticipantsRequest extends Component { title: 'CONTACTS', data: this.state.personalDetails, shouldShow: this.state.personalDetails.length > 0, - indexOffset: sections.reduce((prev, {data}) => prev + data.length, 0), + indexOffset: 0, }); if (this.state.userToInvite) { diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js index ea5cdf45555a..0aa0cafe7ed5 100644 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js @@ -109,6 +109,9 @@ class IOUParticipantsSplit extends Component { title: 'RECENTS', data: this.state.recentReports, shouldShow: this.state.recentReports.length > 0, + + // takes the sum off the length of all data + // (this.state.selectedOptions) in previous sections indexOffset: sections.reduce((prev, {data}) => prev + data.length, 0), }); @@ -116,6 +119,9 @@ class IOUParticipantsSplit extends Component { title: 'CONTACTS', data: this.state.personalDetails, shouldShow: this.state.personalDetails.length > 0, + + // takes the sum off the length of all data + // (this.state.selectedOptions, this.state.recentReports) in previous sections indexOffset: sections.reduce((prev, {data}) => prev + data.length, 0), }); diff --git a/src/pages/iou/steps/IOUParticipantsPage/index.js b/src/pages/iou/steps/IOUParticipantsPage/index.js index 6655cbb265d3..2660f73092a5 100644 --- a/src/pages/iou/steps/IOUParticipantsPage/index.js +++ b/src/pages/iou/steps/IOUParticipantsPage/index.js @@ -48,7 +48,6 @@ const defaultProps = { }; const IOUParticipantsPage = (props) => { - console.debug(props.participants); if (props.iou.loading) { return (