Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update request money header title #29936

Merged
merged 10 commits into from
Oct 27, 2023
4 changes: 3 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -2829,9 +2829,11 @@ function setMoneyRequestBillable(billable) {

/**
* @param {Object[]} participants
* @param {Boolean} isSplitRequest
*/
function setMoneyRequestParticipants(participants) {
function setMoneyRequestParticipants(participants, isSplitRequest) {
Onyx.merge(ONYXKEYS.IOU, {participants});
Onyx.merge(ONYXKEYS.IOU, {isSplitRequest});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Onyx.merge(ONYXKEYS.IOU, {isSplitRequest});

Let's use one merge :

Onyx.merge(ONYXKEYS.IOU, {participants, isSplitRequest});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedirjh Quickly updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @DylanDylann I think there is one more change needed, let's pass an empty array when iou.isSplitRequest is false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a little bug: when closing the modal without splitting the request, the default type is set to 'split'

bugDesktop.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @DylanDylann I think there is one more change needed, let's pass an empty array when iou.isSplitRequest is false.

@fedirjh I think it is unnecessary, currently as code change we have 2 cases iou.isSplitRequest = false

  1. In function addSingleParticipant (manual case) we must pass participants param
  2. In function addParticipantToSelection, isSplitRequest = false when newSelectedOptions.length === 0 which means newSelectedOptions is empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is unnecessary

@DylanDylann We have this bug, from a manual request, navigating back to the participant's page will display selected user + 'add to split button' in the bottom

CleanShot.2023-10-26.at.12.20.13.mp4

}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ function MoneyRequestConfirmPage(props) {
return props.translate('common.send');
}

if (isScanRequest) {
return props.translate('tabSelector.scan');
}

return props.translate('tabSelector.manual');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) {
return;
}

setHeaderTitle(_.isEmpty(iou.participants) ? translate('tabSelector.manual') : translate('iou.split'));
}, [iou.participants, isDistanceRequest, isSendRequest, translate]);
if (isScanRequest) {
setHeaderTitle(translate('tabSelector.scan'));
return;
}

setHeaderTitle(iou.isSplitRequest ? translate('iou.split') : translate('tabSelector.manual'));
}, [iou.isSplitRequest, isDistanceRequest, translate, isScanRequest, isSendRequest]);

const navigateToConfirmationStep = (moneyRequestType) => {
IOU.setMoneyRequestId(moneyRequestType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ function MoneyRequestParticipantsSelector({
* @param {Object} option
*/
const addSingleParticipant = (option) => {
onAddParticipants([
{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText},
]);
onAddParticipants(
[{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText}],
false,
);
navigateToRequest();
};

Expand Down Expand Up @@ -197,8 +198,7 @@ function MoneyRequestParticipantsSelector({
},
];
}

onAddParticipants(newSelectedOptions);
onAddParticipants(newSelectedOptions, newSelectedOptions.length !== 0);
},
[participants, onAddParticipants],
);
Expand Down
Loading