Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ function MoneyRequestConfirmationList(props) {
return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(payeePersonalDetails)];
}, [selectedParticipants, props.hasMultipleParticipants, payeePersonalDetails]);

const distanceMerchant = useMemo(() => DistanceRequestUtils.getDistanceMerchant(distance, unit, rate, currency, translate), [distance, unit, rate, currency, translate]);

useEffect(() => {
IOU.setMoneyRequestMerchant(distanceMerchant);

@hayata-suenaga hayata-suenaga Sep 2, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like this pattern though.

We should get the distance request merchant string and set the string in IOU at the same place.

We can put the following code inside useEffect with the dependency array.

const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(distance, unit, rate, currency, translate)
IOU.setMoneyRequestMerchant(distanceMerchant);

And for the title of MenuItemWithTopDescription, we can pass iou.merchant instead.

I gonna approve this PR right now, but please make a follow up PR @jeet-dhandha for the cleanup 🙇

We consider the issue to be complete after the follow-up PR is merged 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

}, [distanceMerchant]);

/**
* @param {Object} option
*/
Expand Down Expand Up @@ -457,7 +463,7 @@ function MoneyRequestConfirmationList(props) {
{props.isDistanceRequest ? (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly && isTypeRequest}
title={DistanceRequestUtils.getDistanceMerchant(distance, unit, rate, currency, translate)}
title={distanceMerchant}
description={translate('common.distance')}
style={[styles.moneyRequestMenuItem, styles.mb2]}
titleStyle={styles.flex1}
Expand Down
5 changes: 4 additions & 1 deletion src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ function getLinkedTransaction(reportAction = {}) {
}

function getAllReportTransactions(reportID) {
return _.filter(allTransactions, (transaction) => transaction.reportID === reportID);
// `reportID` from the `/CreateDistanceRequest` endpoint return's number instead of string for created `transaction`.
// For reference, https://github.com/Expensify/App/pull/26536#issuecomment-1703573277.
// We will update this in a follow-up Issue. According to this comment: https://github.com/Expensify/App/pull/26536#issuecomment-1703591019.
return _.filter(allTransactions, (transaction) => `${transaction.reportID}` === `${reportID}`);
Comment thread
hayata-suenaga marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we still need this change ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can test it out and see. Hopefully it has been fixed.

}

/**
Expand Down
11 changes: 7 additions & 4 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,19 @@ function getMoneyRequestInformation(
* @param {String} comment
* @param {String} created
* @param {String} [transactionID]
* @param {Number} amount
* @param {String} currency
* @param {String} merchant
*/
function createDistanceRequest(report, participant, comment, created, transactionID) {
function createDistanceRequest(report, participant, comment, created, transactionID, amount, currency, merchant) {
const {iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation(
report,
participant,
comment,
0,
'USD',
amount,
currency,
created,
'',
merchant,
null,
null,
null,
Expand Down
13 changes: 11 additions & 2 deletions src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,18 @@ function MoneyRequestConfirmPage(props) {
*/
const createDistanceRequest = useCallback(
(selectedParticipants, trimmedComment) => {
IOU.createDistanceRequest(props.report, selectedParticipants[0], trimmedComment, props.iou.created, props.iou.transactionID);
IOU.createDistanceRequest(
props.report,
selectedParticipants[0],
trimmedComment,
props.iou.created,
props.iou.transactionID,
props.iou.amount,
props.iou.currency,
props.iou.merchant,
);
},
[props.report, props.iou.created, props.iou.transactionID],
[props.report, props.iou.created, props.iou.transactionID, props.iou.amount, props.iou.currency, props.iou.merchant],
);

const createTransaction = useCallback(
Expand Down