Skip to content

Commit 2d5bea5

Browse files
authored
Merge pull request #27055 from Expensify/yuwen-copyCategory
[NoQA] Copy category over from expense when Editing a Money Request
2 parents 28b9cee + b71fafa commit 2d5bea5

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/libs/ReportUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ function getTransactionDetails(transaction) {
12861286
currency: TransactionUtils.getCurrency(transaction),
12871287
comment: TransactionUtils.getDescription(transaction),
12881288
merchant: TransactionUtils.getMerchant(transaction),
1289+
category: TransactionUtils.getCategory(transaction),
12891290
};
12901291
}
12911292

src/libs/TransactionUtils.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ function getMerchant(transaction) {
231231
return lodashGet(transaction, 'modifiedMerchant', null) || lodashGet(transaction, 'merchant', '');
232232
}
233233

234+
/**
235+
* Return the category from the transaction. This "category" field has no "modified" complement.
236+
*
237+
* @param {Object} transaction
238+
* @return {String}
239+
*/
240+
function getCategory(transaction) {
241+
return lodashGet(transaction, 'category', '');
242+
}
243+
234244
/**
235245
* Return the created field from the transaction, return the modifiedCreated if present.
236246
*
@@ -365,6 +375,7 @@ export {
365375
getCurrency,
366376
getMerchant,
367377
getCreated,
378+
getCategory,
368379
getLinkedTransaction,
369380
getAllReportTransactions,
370381
hasReceipt,

src/libs/actions/IOU.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC
10961096
];
10971097

10981098
// STEP 6: Call the API endpoint
1099-
const {created, amount, currency, comment, merchant} = ReportUtils.getTransactionDetails(updatedTransaction);
1099+
const {created, amount, currency, comment, merchant, category} = ReportUtils.getTransactionDetails(updatedTransaction);
11001100
API.write(
11011101
'EditMoneyRequest',
11021102
{
@@ -1107,6 +1107,7 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC
11071107
currency,
11081108
comment,
11091109
merchant,
1110+
category,
11101111
},
11111112
{optimisticData, successData, failureData},
11121113
);

0 commit comments

Comments
 (0)