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

🍒 Cherry pick PR #18981 to staging 🍒 #19116

Merged
merged 2 commits into from
May 17, 2023
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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001031502
versionName "1.3.15-2"
versionCode 1001031503
versionName "1.3.15-3"
}

splits {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.3.15.2</string>
<string>1.3.15.3</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.15.2</string>
<string>1.3.15.3</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.3.15-2",
"version": "1.3.15-3",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/IOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const IOUPreview = (props) => {
const moneyRequestAction = ReportUtils.getMoneyRequestAction(props.action);

// If props.action is undefined then we are displaying within IOUDetailsModal and should use the full report amount
const requestAmount = props.isIOUAction ? moneyRequestAction.total : ReportUtils.getMoneyRequestTotal(props.iouReport);
const requestAmount = props.isIOUAction ? moneyRequestAction.amount : ReportUtils.getMoneyRequestTotal(props.iouReport);
const requestCurrency = props.isIOUAction ? moneyRequestAction.currency : props.iouReport.currency;
const requestComment = Str.htmlDecode(moneyRequestAction.comment).trim();

Expand Down
6 changes: 3 additions & 3 deletions src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as OptionsListUtils from '../../libs/OptionsListUtils';
import * as ReportUtils from '../../libs/ReportUtils';
import * as Report from '../../libs/actions/Report';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import * as CurrencyUtils from '../../libs/CurrencyUtils';
import * as ReportActionsUtils from '../../libs/ReportActionsUtils';

const propTypes = {
/** All the data of the action */
Expand Down Expand Up @@ -99,8 +99,8 @@ const MoneyRequestAction = (props) => {
const formattedUserLogins = _.map(participants, (login) => OptionsListUtils.addSMSDomainIfPhoneNumber(login).toLowerCase());
const thread = ReportUtils.buildOptimisticChatReport(
formattedUserLogins,
props.translate('iou.threadReportName', {
formattedAmount: CurrencyUtils.convertToDisplayString(lodashGet(props.action, 'originalMessage.amount', 0), lodashGet(props.action, 'originalMessage.currency', '')),
props.translate(ReportActionsUtils.isSentMoneyReportAction(props.action) ? 'iou.threadSentMoneyReportName' : 'iou.threadRequestReportName', {
formattedAmount: ReportActionsUtils.getFormattedAmount(props.action),
comment: props.action.originalMessage.comment,
}),
'',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ export default {
payerSettled: ({amount}) => `settled up ${amount}`,
noReimbursableExpenses: 'This report has an invalid amount',
pendingConversionMessage: "Total will update when you're back online",
threadReportName: ({formattedAmount, comment}) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`,
threadRequestReportName: ({formattedAmount, comment}) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`,
threadSentMoneyReportName: ({formattedAmount, comment}) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`,
error: {
invalidSplit: 'Split amounts do not equal total amount',
other: 'Unexpected error, please try again later',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ export default {
payerSettled: ({amount}) => `pagado ${amount}`,
noReimbursableExpenses: 'El monto de este informe es inválido',
pendingConversionMessage: 'El total se actualizará cuando estés online',
threadReportName: ({formattedAmount, comment}) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
threadRequestReportName: ({formattedAmount, comment}) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
threadSentMoneyReportName: ({formattedAmount, comment}) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`,
error: {
invalidSplit: 'La suma de las partes no equivale al monto total',
other: 'Error inesperado, por favor inténtalo más tarde',
Expand Down
38 changes: 36 additions & 2 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as CollectionUtils from './CollectionUtils';
import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';
import Log from './Log';
import * as CurrencyUtils from './CurrencyUtils';
import isReportMessageAttachment from './isReportMessageAttachment';

const allReportActions = {};
Expand Down Expand Up @@ -61,16 +62,47 @@ function getParentReportAction(report) {
return lodashGet(allReportActions, [report.parentReportID, report.parentReportActionID], {});
}

/**
* Determines if the given report action is sent money report action by checking for 'pay' type and presence of IOUDetails object.
*
* @param {Object} reportAction
* @returns {Boolean}
*/
function isSentMoneyReportAction(reportAction) {
return (
reportAction &&
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU &&
lodashGet(reportAction, 'originalMessage.type') === CONST.IOU.REPORT_ACTION_TYPE.PAY &&
_.has(reportAction.originalMessage, 'IOUDetails')
);
}

/**
* Returns the formatted amount of a money request. The request and money sent (from send money flow) have
* currency and amount in IOUDetails object.
*
* @param {Object} reportAction
* @returns {Number}
*/
function getFormattedAmount(reportAction) {
return lodashGet(reportAction, 'originalMessage.type', '') === CONST.IOU.REPORT_ACTION_TYPE.PAY && lodashGet(reportAction, 'originalMessage.IOUDetails', false)
? CurrencyUtils.convertToDisplayString(lodashGet(reportAction, 'originalMessage.IOUDetails.amount', 0), lodashGet(reportAction, 'originalMessage.IOUDetails.currency', ''))
: CurrencyUtils.convertToDisplayString(lodashGet(reportAction, 'originalMessage.amount', 0), lodashGet(reportAction, 'originalMessage.currency', ''));
}

/**
* Returns whether the thread is a transaction thread, which is any thread with IOU parent
* report action of type create.
* report action from requesting money (type - create) or from sending money (type - pay with IOUDetails field)
*
* @param {Object} parentReportAction
* @returns {Boolean}
*/
function isTransactionThread(parentReportAction) {
const originalMessage = lodashGet(parentReportAction, 'originalMessage', {});
return (
parentReportAction && parentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && lodashGet(parentReportAction, 'originalMessage.type') === CONST.IOU.REPORT_ACTION_TYPE.CREATE
parentReportAction &&
parentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU &&
(originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && originalMessage.IOUDetails))
);
}

Expand Down Expand Up @@ -371,4 +403,6 @@ export {
isCreatedTaskReportAction,
getParentReportAction,
isTransactionThread,
getFormattedAmount,
isSentMoneyReportAction,
};
10 changes: 5 additions & 5 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,17 +971,17 @@ function getDisplayNamesWithTooltips(participants, isMultipleParticipantReport)
*/
function getMoneyRequestAction(reportAction = {}) {
const originalMessage = lodashGet(reportAction, 'originalMessage', {});
let total = originalMessage.amount || 0;
let amount = originalMessage.amount || 0;
let currency = originalMessage.currency || CONST.CURRENCY.USD;
let comment = originalMessage.comment || '';

if (_.has(originalMessage, 'IOUDetails')) {
total = lodashGet(originalMessage, 'IOUDetails.amount', 0);
amount = lodashGet(originalMessage, 'IOUDetails.amount', 0);
currency = lodashGet(originalMessage, 'IOUDetails.currency', CONST.CURRENCY.USD);
comment = lodashGet(originalMessage, 'IOUDetails.comment', '');
}

return {total, currency, comment};
return {amount, currency, comment};
}

/**
Expand Down Expand Up @@ -1055,8 +1055,8 @@ function getMoneyRequestReportName(report) {
* @returns {String}
*/
function getTransactionReportName(reportAction) {
return Localize.translateLocal('iou.threadReportName', {
formattedAmount: CurrencyUtils.convertToDisplayString(lodashGet(reportAction, 'originalMessage.amount', 0), lodashGet(reportAction, 'originalMessage.currency', '')),
return Localize.translateLocal(ReportActionsUtils.isSentMoneyReportAction(reportAction) ? 'iou.threadSentMoneyReportName' : 'iou.threadRequestReportName', {
formattedAmount: ReportActionsUtils.getFormattedAmount(reportAction),
comment: lodashGet(reportAction, 'originalMessage.comment'),
});
}
Expand Down
10 changes: 7 additions & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,17 @@ class ReportActionItem extends Component {
*/
renderItemContent(hovered = false) {
let children;
const originalMessage = lodashGet(this.props.action, 'originalMessage', {});
// Show the IOUPreview for when request was created, bill was split or money was sent
if (
this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU &&
this.props.action.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.DELETE &&
this.props.action.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.PAY
originalMessage &&
(originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE ||
originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT ||
(originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && originalMessage.IOUDetails))
) {
// There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID
const iouReportID = this.props.action.originalMessage.IOUReportID ? this.props.action.originalMessage.IOUReportID.toString() : '0';
const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0';

children = (
<MoneyRequestAction
Expand Down