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 #19194 to staging 🍒 #19262

Merged
merged 2 commits into from
May 19, 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 1001031604
versionName "1.3.16-4"
versionCode 1001031605
versionName "1.3.16-5"
}

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.16.4</string>
<string>1.3.16.5</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.16.4</string>
<string>1.3.16.5</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.16-4",
"version": "1.3.16-5",
"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
6 changes: 3 additions & 3 deletions src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ const MoneyRequestHeader = (props) => {
? ReportUtils.getWorkspaceAvatar(moneyRequestReport)
: ReportUtils.getAvatar(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'avatar']), moneyRequestReport.managerEmail);
const policy = props.policies[`${ONYXKEYS.COLLECTION.POLICY}${props.report.policyID}`];
const shouldShowSettlementButton =
!isSettled && (Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(props.report) && lodashGet(props.session, 'email', null) === props.report.managerEmail));
const isPayer = Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(props.report) && lodashGet(props.session, 'email', null) === props.report.managerEmail);
const shouldShowSettlementButton = !isSettled && !props.isSingleTransactionView && isPayer;
return (
<View style={[{backgroundColor: themeColors.highlightBG}, styles.pl0]}>
<HeaderWithCloseButton
Expand Down Expand Up @@ -149,7 +149,7 @@ const MoneyRequestHeader = (props) => {
currency={props.report.currency}
policyID={props.report.policyID}
shouldShowPaypal={Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'payPalMeAddress']))}
chatReportID={props.report.chatReportID}
chatReportID={props.chatReport.reportID}
iouReport={props.report}
onPress={(paymentType) => IOU.payMoneyRequest(paymentType, props.chatReport, props.report)}
enablePaymentsRoute={ROUTES.BANK_ACCOUNT_NEW}
Expand Down
8 changes: 5 additions & 3 deletions src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const ReportPreview = (props) => {
const isCurrentUserManager = managerEmail === lodashGet(props.session, 'email', null);
return (
<View style={[styles.chatItemMessage, styles.mt4]}>
{_.map(props.action.message, (index) => (
{_.map(props.action.message, (message, index) => (
<Pressable
key={`ReportPreview-${props.action.reportActionID}-${index}`}
onPress={() => {
Expand All @@ -114,10 +114,12 @@ const ReportPreview = (props) => {
>
<View style={[styles.flexShrink1]}>
{props.iouReport.hasOutstandingIOU ? (
<Text style={[styles.chatItemMessage, styles.cursorPointer]}>{props.translate('iou.payerOwesAmount', {payer: managerName, amount: reportAmount})}</Text>
<Text style={[styles.chatItemMessage, styles.cursorPointer]}>
{lodashGet(message, 'html', props.translate('iou.payerOwesAmount', {payer: managerName, amount: reportAmount}))}
</Text>
) : (
<View style={[styles.flexRow]}>
<Text style={[styles.chatItemMessage, styles.cursorPointer]}>{props.translate('iou.payerSettled', {amount: reportAmount})}</Text>
<Text style={[styles.chatItemMessage, styles.cursorPointer]}>{lodashGet(message, 'html', props.translate('iou.payerSettled', {amount: reportAmount}))}</Text>
{!props.iouReport.hasOutstandingIOU && (
<Icon
style={[styles.ml10]}
Expand Down
5 changes: 3 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,9 +1383,10 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType =
* @param {String} [paymentType] - Only required if the IOUReportAction type is 'pay'. Can be oneOf(elsewhere, payPal, Expensify).
* @param {String} [iouReportID] - Only required if the IOUReportActions type is oneOf(decline, cancel, pay). Generates a randomID as default.
* @param {Boolean} [isSettlingUp] - Whether we are settling up an IOU.
* @param {Boolean} [isSendMoneyFlow] - Whether this is send money flow
* @returns {Object}
*/
function buildOptimisticIOUReportAction(type, amount, currency, comment, participants, transactionID, paymentType = '', iouReportID = '', isSettlingUp = false) {
function buildOptimisticIOUReportAction(type, amount, currency, comment, participants, transactionID, paymentType = '', iouReportID = '', isSettlingUp = false, isSendMoneyFlow = false) {
const IOUReportID = iouReportID || generateReportID();
const parser = new ExpensiMark();
const commentText = getParsedComment(comment);
Expand All @@ -1401,7 +1402,7 @@ function buildOptimisticIOUReportAction(type, amount, currency, comment, partici
};

// We store amount, comment, currency in IOUDetails when type = pay
if (type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
if (type === CONST.IOU.REPORT_ACTION_TYPE.PAY && isSendMoneyFlow) {
_.each(['amount', 'comment', 'currency'], (key) => {
delete originalMessage[key];
});
Expand Down
21 changes: 2 additions & 19 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType
optimisticTransaction.transactionID,
paymentMethodType,
optimisticIOUReport.reportID,
false,
true,
);

// First, add data that will be used in all cases
Expand Down Expand Up @@ -1014,7 +1016,6 @@ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType
* @returns {Object}
*/
function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMethodType) {
const reportPreviewAction = ReportActionsUtils.getReportPreviewAction(chatReport.reportID, iouReport.reportID);
const optimisticTransaction = TransactionUtils.buildOptimisticTransaction(iouReport.total, iouReport.currency, iouReport.reportID);
const optimisticIOUReportAction = ReportUtils.buildOptimisticIOUReportAction(
CONST.IOU.REPORT_ACTION_TYPE.PAY,
Expand Down Expand Up @@ -1042,15 +1043,6 @@ function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMetho
lastMessageHtml: optimisticIOUReportAction.message[0].html,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`,
value: {
[reportPreviewAction.reportActionID]: {
created: DateUtils.getDBTime(),
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
Expand Down Expand Up @@ -1104,15 +1096,6 @@ function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMetho
];

const failureData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`,
value: {
[reportPreviewAction.reportActionID]: {
created: reportPreviewAction.created,
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.reportID}`,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,10 @@ class ReportActionItem extends Component {
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))
(originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && _.has(originalMessage, 'IOUDetails')))
) {
// There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID
const iouReportID = originalMessage.IOUReportID ? originalMessage.IOUReportID.toString() : '0';

children = (
<MoneyRequestAction
chatReportID={this.props.report.reportID}
Expand Down