Skip to content

Commit

Permalink
Merge branch 'main' into 289Adam289/51966-update-grammar-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
289Adam289 committed Dec 9, 2024
2 parents 40e4b77 + d007785 commit 31f4d33
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 15 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1009007201
versionName "9.0.72-1"
versionCode 1009007300
versionName "9.0.73-0"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
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>9.0.72</string>
<string>9.0.73</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.0.72.1</string>
<string>9.0.73.0</string>
<key>FullStory</key>
<dict>
<key>OrgId</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>9.0.72</string>
<string>9.0.73</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9.0.72.1</string>
<string>9.0.73.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 @@ -11,9 +11,9 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleShortVersionString</key>
<string>9.0.72</string>
<string>9.0.73</string>
<key>CFBundleVersion</key>
<string>9.0.72.1</string>
<string>9.0.73.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": "9.0.72-1",
"version": "9.0.73-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
3 changes: 3 additions & 0 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const isDraft = ReportUtils.isOpenExpenseReport(moneyRequestReport);
const connectedIntegration = PolicyUtils.getConnectedIntegration(policy);
const navigateBackToAfterDelete = useRef<Route>();
const hasHeldExpenses = ReportUtils.hasHeldExpenses(moneyRequestReport?.reportID);
const hasScanningReceipt = ReportUtils.getTransactionsWithReceipts(moneyRequestReport?.reportID).some((t) => TransactionUtils.isReceiptBeingScanned(t));
const hasOnlyPendingTransactions = allTransactions.length > 0 && allTransactions.every((t) => TransactionUtils.isExpensifyCardTransaction(t) && TransactionUtils.isPending(t));
const transactionIDs = allTransactions.map((t) => t.transactionID);
Expand Down Expand Up @@ -361,6 +362,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
{shouldShowSettlementButton && !shouldUseNarrowLayout && (
<View style={styles.pv2}>
<SettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
onlyShowPayElsewhere={onlyShowPayElsewhere}
currency={moneyRequestReport?.currency}
confirmApproval={confirmApproval}
Expand Down Expand Up @@ -426,6 +428,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
)}
{shouldShowSettlementButton && shouldUseNarrowLayout && (
<SettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
wrapperStyle={[styles.flex1]}
onlyShowPayElsewhere={onlyShowPayElsewhere}
currency={moneyRequestReport?.currency}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ function ReportPreview({
const [isPaidAnimationRunning, setIsPaidAnimationRunning] = useState(false);
const [isHoldMenuVisible, setIsHoldMenuVisible] = useState(false);
const [requestType, setRequestType] = useState<ActionHandledType>();

const [paymentType, setPaymentType] = useState<PaymentMethodType>();

const getCanIOUBePaid = useCallback(
Expand All @@ -140,6 +139,7 @@ function ReportPreview({

const {nonHeldAmount, fullAmount, hasValidNonHeldAmount} = ReportUtils.getNonHeldAndFullAmount(iouReport, shouldShowPayButton);
const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(iouReport?.reportID ?? '');
const hasHeldExpenses = ReportUtils.hasHeldExpenses(iouReport?.reportID ?? '');

const managerID = iouReport?.managerID ?? action.childManagerAccountID ?? 0;
const {totalDisplaySpend, reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport);
Expand Down Expand Up @@ -534,6 +534,7 @@ function ReportPreview({
</View>
{shouldShowSettlementButton && (
<AnimatedSettlementButton
shouldUseSuccessStyle={!hasHeldExpenses}
onlyShowPayElsewhere={onlyShowPayElsewhere}
isPaidAnimationRunning={isPaidAnimationRunning}
onAnimationFinish={stopAnimation}
Expand Down
4 changes: 3 additions & 1 deletion src/components/SelectionList/Search/ActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const actionTranslationsMap: Record<SearchTransactionAction, TranslationPaths> =

type ActionCellProps = {
action?: SearchTransactionAction;
shouldUseSuccessStyle?: boolean;
isLargeScreenWidth?: boolean;
isSelected?: boolean;
goToItem: () => void;
Expand All @@ -35,6 +36,7 @@ type ActionCellProps = {

function ActionCell({
action = CONST.SEARCH.ACTION_TYPES.VIEW,
shouldUseSuccessStyle = true,
isLargeScreenWidth = true,
isSelected = false,
goToItem,
Expand Down Expand Up @@ -99,7 +101,7 @@ function ActionCell({
style={[styles.w100]}
innerStyles={buttonInnerStyles}
isLoading={isLoading}
success
success={shouldUseSuccessStyle}
isDisabled={isOffline}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type ExpenseItemHeaderNarrowProps = {
containerStyle?: StyleProp<ViewStyle>;
onButtonPress: () => void;
canSelectMultiple?: boolean;
shouldUseSuccessStyle?: boolean;
isSelected?: boolean;
isDisabled?: boolean | null;
isDisabledCheckbox?: boolean;
Expand All @@ -41,6 +42,7 @@ function ExpenseItemHeaderNarrow({
canSelectMultiple,
containerStyle,
isDisabledCheckbox,
shouldUseSuccessStyle = true,
isSelected,
isDisabled,
handleCheckboxPress,
Expand Down Expand Up @@ -101,6 +103,7 @@ function ExpenseItemHeaderNarrow({
<View style={[StyleUtils.getWidthStyle(variables.w80)]}>
<ActionCell
action={action}
shouldUseSuccessStyle={shouldUseSuccessStyle}
goToItem={onButtonPress}
isLargeScreenWidth={false}
isSelected={isSelected}
Expand Down
4 changes: 4 additions & 0 deletions src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {handleActionButtonPress} from '@libs/actions/Search';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -109,6 +110,8 @@ function ReportListItem<TItem extends ListItem>({
return null;
}

const hasHeldExpenses = ReportUtils.hasHeldExpenses('', reportItem.transactions);

const participantFrom = reportItem.from;
const participantTo = reportItem.to;

Expand Down Expand Up @@ -202,6 +205,7 @@ function ReportListItem<TItem extends ListItem>({
<View style={StyleUtils.getSearchTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)}>
<ActionCell
action={reportItem.action}
shouldUseSuccessStyle={!hasHeldExpenses}
goToItem={handleOnButtonPress}
isSelected={item.isSelected}
isLoading={reportItem.isActionLoading}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Str} from 'expensify-common';
import React from 'react';
import React, {useMemo} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
import Checkbox from '@components/Checkbox';
Expand Down Expand Up @@ -265,6 +265,8 @@ function TransactionListItemRow({
const StyleUtils = useStyleUtils();
const theme = useTheme();

const isOnHold = useMemo(() => TransactionUtils.isOnHold(item), [item]);

if (!isLargeScreenWidth) {
return (
<View style={containerStyle}>
Expand All @@ -278,6 +280,7 @@ function TransactionListItemRow({
onButtonPress={onButtonPress}
canSelectMultiple={canSelectMultiple}
action={item.action}
shouldUseSuccessStyle={!isOnHold}
isSelected={item.isSelected}
isDisabled={item.isDisabled}
isDisabledCheckbox={item.isDisabledCheckbox}
Expand Down Expand Up @@ -444,6 +447,7 @@ function TransactionListItemRow({
<View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.ACTION)]}>
<ActionCell
action={item.action}
shouldUseSuccessStyle={!isOnHold}
isSelected={isButtonSelected}
isChildListItem={isChildListItem}
parentAction={parentAction}
Expand Down
2 changes: 2 additions & 0 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function SettlementButton({
onPress,
pressOnEnter = false,
policyID = '-1',
shouldUseSuccessStyle = true,
shouldHidePaymentOptions = false,
shouldShowApproveButton = false,
shouldDisableApproveButton = false,
Expand Down Expand Up @@ -234,6 +235,7 @@ function SettlementButton({
>
{(triggerKYCFlow, buttonRef) => (
<ButtonWithDropdownMenu<PaymentType>
success={shouldUseSuccessStyle}
onOptionsMenuShow={onPaymentOptionsShow}
onOptionsMenuHide={onPaymentOptionsHide}
buttonRef={buttonRef}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SettlementButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ type SettlementButtonProps = {
/** The IOU/Expense report we are paying */
iouReport?: OnyxEntry<Report>;

/** Whether to use the success style or not */
shouldUseSuccessStyle?: boolean;

/** Should we show the payment options? */
shouldHidePaymentOptions?: boolean;

Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): bool
return isAwaitingFirstLevelApproval(moneyRequestReport);
}

if (isReportApproved(moneyRequestReport) || isSettled(moneyRequestReport?.reportID)) {
if (isReportApproved(moneyRequestReport) || isClosedReport(moneyRequestReport) || isSettled(moneyRequestReport?.reportID)) {
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7568,6 +7568,10 @@ function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, chatReport: O
const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATE_NUM.SUBMITTED : CONST.REPORT.STATE_NUM.APPROVED;
const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;
const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, statusNum);
const iouReportActions = ReportActionsUtils.getAllReportActions(chatReport.iouReportID ?? '-1');
const expenseReportActions = ReportActionsUtils.getAllReportActions(expenseReport.reportID ?? '-1');
const iouCreatedAction = Object.values(iouReportActions).find((action) => ReportActionsUtils.isCreatedAction(action));
const expenseCreatedAction = Object.values(expenseReportActions).find((action) => ReportActionsUtils.isCreatedAction(action));
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -7579,6 +7583,14 @@ function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, chatReport: O
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`,
value: {
// The report created later will become the iouReportID of the chat report
iouReportID: (iouCreatedAction?.created ?? '') > (expenseCreatedAction?.created ?? '') ? chatReport?.iouReportID : expenseReport.reportID,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`,
Expand Down
90 changes: 90 additions & 0 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,96 @@ describe('actions/IOU', () => {
});
});

describe('a workspace chat with a cancelled payment', () => {
const amount = 10000;
const comment = '💸💸💸💸';
const merchant = 'NASDAQ';

afterEach(() => {
mockFetch?.resume?.();
});

it("has an iouReportID of the cancelled payment's expense report", () => {
let expenseReport: OnyxEntry<OnyxTypes.Report>;
let chatReport: OnyxEntry<OnyxTypes.Report>;

// Given a signed in account, which owns a workspace, and has a policy expense chat
Onyx.set(ONYXKEYS.SESSION, {email: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID});
return waitForBatchedUpdates()
.then(() => {
// Which owns a workspace
PolicyActions.createWorkspace(CARLOS_EMAIL, true, "Carlos's Workspace");
return waitForBatchedUpdates();
})
.then(() =>
TestHelper.getOnyxData({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (allReports) => {
chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT);
},
}),
)
.then(() => {
if (chatReport) {
// When an IOU expense is submitted to that policy expense chat
IOU.requestMoney({
report: chatReport,
participantParams: {
payeeEmail: RORY_EMAIL,
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
created: '',
merchant,
comment,
},
});
}
return waitForBatchedUpdates();
})
.then(() =>
// And given an expense report has now been created which holds the IOU
TestHelper.getOnyxData({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (allReports) => {
expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU);
},
}),
)
.then(() => {
// When the expense report is paid elsewhere (but really, any payment option would work)
if (chatReport && expenseReport) {
IOU.payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport);
}
return waitForBatchedUpdates();
})
.then(() => {
if (chatReport && expenseReport) {
// And when the payment is cancelled
IOU.cancelPayment(expenseReport, chatReport);
}
return waitForBatchedUpdates();
})
.then(() =>
TestHelper.getOnyxData({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (allReports) => {
const chatReportData = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`];
// Then the policy expense chat report has the iouReportID of the IOU expense report
expect(chatReportData?.iouReportID).toBe(expenseReport?.reportID);
},
}),
);
});
});

describe('deleteMoneyRequest', () => {
const amount = 10000;
const comment = 'Send me money please';
Expand Down
Loading

0 comments on commit 31f4d33

Please sign in to comment.