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
8 changes: 8 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,13 @@ function setMoneyRequestParticipants(participants) {
Onyx.merge(ONYXKEYS.IOU, {participants});
}

/**
* @param {Boolean} isSplitRequest
*/
function setMoneyRequestIsSplitRequest(isSplitRequest) {
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

}
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 would be better to update the existing code of setMoneyRequestParticipants instead of creating a new one.

Let's add new parameter to the setMoneyRequestParticipants function.

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 Thank you for your comment, please check again


/**
* @param {String} receiptPath
* @param {String} receiptFilename
Expand Down Expand Up @@ -2941,6 +2948,7 @@ export {
resetMoneyRequestTag,
setMoneyRequestBillable,
setMoneyRequestParticipants,
setMoneyRequestIsSplitRequest,
setMoneyRequestReceipt,
setUpDistanceTransaction,
navigateToNextPage,
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 @@ -16,6 +16,7 @@ import CONST from '../../../../CONST';
import personalDetailsPropType from '../../../personalDetailsPropType';
import reportPropTypes from '../../../reportPropTypes';
import refPropTypes from '../../../../components/refPropTypes';
import * as IOU from '../../../../libs/actions/IOU';

const propTypes = {
/** Beta features list */
Expand Down Expand Up @@ -159,6 +160,7 @@ function MoneyRequestParticipantsSelector({
onAddParticipants([
{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText},
]);
IOU.setMoneyRequestIsSplitRequest(false);
navigateToRequest();
};

Expand Down Expand Up @@ -198,6 +200,11 @@ function MoneyRequestParticipantsSelector({
];
}

if (newSelectedOptions.length === 0) {
IOU.setMoneyRequestIsSplitRequest(false);
} else {
IOU.setMoneyRequestIsSplitRequest(true);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's avoid these extra steps, let's update onAddParticipants to accept new parameter instead.

onAddParticipants(newSelectedOptions);
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 the best option is to use a new optimistic prop inside the IOU to store the type of the request, something like iou.isSplitRequest and then update it when we select multiple participants, what do you think?

},
[participants, onAddParticipants],
Expand Down
Loading