Skip to content

Commit

Permalink
Avoid repeating logic at every component render.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristipaval committed Apr 13, 2023
1 parent 4f995a9 commit 9754a32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function getPersonalDetailsForLogins(logins, personalDetails) {
/**
* Get the participant options for a report.
* @param {Object} report
* @param {Array<Object>} personalDetailList
* @param {Array<Object>} personalDetails
* @returns {Array}
*/
function getParticipantsOptions(report, personalDetails) {
Expand Down
10 changes: 5 additions & 5 deletions src/pages/iou/MoneyRequestModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ const Steps = {
};

const MoneyRequestModal = (props) => {
const participantsWithDetails = ReportUtils.isPolicyExpenseChat(props.report)
? OptionsListUtils.getPolicyExpenseReportOptions(props.report)
: OptionsListUtils.getParticipantsOptions(props.report, props.personalDetails);

// Skip IOUParticipants step if participants are passed in
const reportParticipants = lodashGet(props, 'report.participants', []);
const steps = reportParticipants.length ? [Steps.MoneyRequestAmount, Steps.MoneyRequestConfirm] : [Steps.MoneyRequestAmount, Steps.MoneyRequestParticipants, Steps.MoneyRequestConfirm];
Expand All @@ -117,7 +113,11 @@ const MoneyRequestModal = (props) => {

const [previousStepIndex, setPreviousStepIndex] = useState(0);
const [currentStepIndex, setCurrentStepIndex] = useState(0);
const [selectedOptions, setSelectedOptions] = useState(participantsWithDetails);
const [selectedOptions, setSelectedOptions] = useState(
ReportUtils.isPolicyExpenseChat(props.report)
? OptionsListUtils.getPolicyExpenseReportOptions(props.report)
: OptionsListUtils.getParticipantsOptions(props.report, props.personalDetails),
);
const [amount, setAmount] = useState('');
const [comment, setComment] = useState('');

Expand Down

0 comments on commit 9754a32

Please sign in to comment.