Skip to content

Commit

Permalink
Merge branch 'main' into fix/27856
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Jan 23, 2024
2 parents d3b3dac + 9c552ab commit ff8e890
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 59 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001042901
versionName "1.4.29-1"
versionCode 1001043000
versionName "1.4.30-0"
}

flavorDimensions "default"
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.29</string>
<string>1.4.30</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.4.29.1</string>
<string>1.4.30.0</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.29</string>
<string>1.4.30</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.29.1</string>
<string>1.4.30.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>1.4.29</string>
<string>1.4.30</string>
<key>CFBundleVersion</key>
<string>1.4.29.1</string>
<string>1.4.30.0</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
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.4.29-1",
"version": "1.4.30-0",
"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
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3133,4 +3133,8 @@ const CONST = {
MINI_CONTEXT_MENU_MAX_ITEMS: 4,
} as const;

type Country = keyof typeof CONST.ALL_COUNTRIES;

export type {Country};

export default CONST;
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
import PropTypes from 'prop-types';
import React, {useEffect} from 'react';
import React, {forwardRef, useEffect} from 'react';
import type {ForwardedRef} from 'react';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {Country} from '@src/CONST';
import ROUTES from '@src/ROUTES';
import FormHelpMessage from './FormHelpMessage';
import MenuItemWithTopDescription from './MenuItemWithTopDescription';
import refPropTypes from './refPropTypes';

const propTypes = {
type CountrySelectorProps = {
/** Form error text. e.g when no country is selected */
errorText: PropTypes.string,
errorText?: string;

/** Callback called when the country changes. */
onInputChange: PropTypes.func.isRequired,
onInputChange: (value?: string) => void;

/** Current selected country */
value: PropTypes.string,
value?: Country;

/** inputID used by the Form component */
// eslint-disable-next-line react/no-unused-prop-types
inputID: PropTypes.string.isRequired,

/** React ref being forwarded to the MenuItemWithTopDescription */
forwardedRef: refPropTypes,
};

const defaultProps = {
errorText: '',
value: undefined,
forwardedRef: () => {},
inputID: string;
};

function CountrySelector({errorText, value: countryCode, onInputChange, forwardedRef}) {
function CountrySelector({errorText = '', value: countryCode, onInputChange}: CountrySelectorProps, ref: ForwardedRef<View>) {
const styles = useThemeStyles();
const {translate} = useLocalize();

Expand All @@ -51,12 +42,12 @@ function CountrySelector({errorText, value: countryCode, onInputChange, forwarde
<MenuItemWithTopDescription
shouldShowRightIcon
title={title}
ref={forwardedRef}
ref={ref}
descriptionTextStyle={countryTitleDescStyle}
description={translate('common.country')}
onPress={() => {
const activeRoute = Navigation.getActiveRouteWithoutParams();
Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY.getRoute(countryCode, activeRoute));
Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY.getRoute(countryCode ?? '', activeRoute));
}}
/>
<View style={styles.ml5}>
Expand All @@ -66,18 +57,6 @@ function CountrySelector({errorText, value: countryCode, onInputChange, forwarde
);
}

CountrySelector.propTypes = propTypes;
CountrySelector.defaultProps = defaultProps;
CountrySelector.displayName = 'CountrySelector';

const CountrySelectorWithRef = React.forwardRef((props, ref) => (
<CountrySelector
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));

CountrySelectorWithRef.displayName = 'CountrySelectorWithRef';

export default CountrySelectorWithRef;
export default forwardRef(CountrySelector);
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST';
import Str from 'expensify-common/lib/str';
import CONST from '@src/CONST';
import type {Country} from '@src/CONST';
import type {
AddressLineParams,
AlreadySignedInParams,
Expand Down Expand Up @@ -106,7 +107,7 @@ type StateValue = {

type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;

type AllCountries = Record<keyof typeof CONST.ALL_COUNTRIES, string>;
type AllCountries = Record<Country, string>;

/* eslint-disable max-len */
export default {
Expand Down
42 changes: 42 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,21 @@ function updateMoneyRequestTag(transactionID, transactionThreadReportID, tag) {
API.write('UpdateMoneyRequestTag', params, onyxData);
}

/**
* Updates the category of a money request
*
* @param {String} transactionID
* @param {Number} transactionThreadReportID
* @param {String} category
*/
function updateMoneyRequestCategory(transactionID, transactionThreadReportID, category) {
const transactionChanges = {
category,
};
const {params, onyxData} = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, true);
API.write('UpdateMoneyRequestCategory', params, onyxData);
}

/**
* Updates the description of a money request
*
Expand Down Expand Up @@ -1957,6 +1972,32 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co
});
});

_.each(participants, (participant) => {
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(participant);
if (!isPolicyExpenseChat) {
return;
}

const optimisticPolicyRecentlyUsedCategories = Policy.buildOptimisticPolicyRecentlyUsedCategories(participant.policyID, category);
const optimisticPolicyRecentlyUsedTags = Policy.buildOptimisticPolicyRecentlyUsedTags(participant.policyID, tag);

if (!_.isEmpty(optimisticPolicyRecentlyUsedCategories)) {
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES}${participant.policyID}`,
value: optimisticPolicyRecentlyUsedCategories,
});
}

if (!_.isEmpty(optimisticPolicyRecentlyUsedTags)) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${participant.policyID}`,
value: optimisticPolicyRecentlyUsedTags,
});
}
});

// Save the new splits array into the transaction's comment in case the user calls CompleteSplitBill while offline
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -3693,6 +3734,7 @@ export {
updateMoneyRequestBillable,
updateMoneyRequestMerchant,
updateMoneyRequestTag,
updateMoneyRequestCategory,
updateMoneyRequestAmountAndCurrency,
updateMoneyRequestDescription,
replaceReceipt,
Expand Down
25 changes: 11 additions & 14 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
});
}, [parentReportAction, fieldToEdit]);

// Update the transaction object and close the modal
function editMoneyRequest(transactionChanges) {
IOU.editMoneyRequest(transaction, report.reportID, transactionChanges);
Navigation.dismissModal(report.reportID);
}

const saveAmountAndCurrency = useCallback(
({amount, currency: newCurrency}) => {
const newAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount));
Expand Down Expand Up @@ -176,6 +170,16 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
[transactionTag, transaction.transactionID, report.reportID],
);

const saveCategory = useCallback(
({category: newCategory}) => {
// In case the same category has been selected, reset the category.
const updatedCategory = newCategory === transactionCategory ? '' : newCategory;
IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory);
Navigation.dismissModal();
},
[transactionCategory, transaction.transactionID, report.reportID],
);

const saveComment = useCallback(
({comment: newComment}) => {
// Only update comment if it has changed
Expand Down Expand Up @@ -235,14 +239,7 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
<EditRequestCategoryPage
defaultCategory={transactionCategory}
policyID={lodashGet(report, 'policyID', '')}
onSubmit={(transactionChanges) => {
let updatedCategory = transactionChanges.category;
// In case the same category has been selected, do reset of the category.
if (transactionCategory === updatedCategory) {
updatedCategory = '';
}
editMoneyRequest({category: updatedCategory});
}}
onSubmit={saveCategory}
/>
);
}
Expand Down

0 comments on commit ff8e890

Please sign in to comment.