Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3be9e08
Allow failed image/receipt uploads to be retried
nyomanjyotisa Dec 25, 2024
3b51763
Allow failed image/receipt uploads to be retried
nyomanjyotisa Dec 25, 2024
9a666b5
ESLint fix
nyomanjyotisa Dec 25, 2024
f1f05e1
test fix
nyomanjyotisa Dec 26, 2024
37850db
Android Native Fix
nyomanjyotisa Dec 27, 2024
7980a1d
Allow failed image/receipt uploads to be retried
nyomanjyotisa Jan 2, 2025
624ec5f
Add action enum
nyomanjyotisa Jan 6, 2025
4d0356d
Merge branch 'main' into issue-50507-2
nyomanjyotisa Jan 7, 2025
f0f1889
ESLint fix
nyomanjyotisa Jan 7, 2025
104f6a4
Allow failed image/receipt uploads to be retried
nyomanjyotisa Jan 9, 2025
13cfcb1
ESLint fix
nyomanjyotisa Jan 9, 2025
5ac07e2
Separate DotIndicatorMessage
nyomanjyotisa Jan 9, 2025
11a6718
Update copy
nyomanjyotisa Jan 10, 2025
802e273
Update translation
nyomanjyotisa Jan 13, 2025
3f65481
Merge branch 'main' into issue-50507-2
nyomanjyotisa Jan 14, 2025
b89f971
IOUTest fix
nyomanjyotisa Jan 14, 2025
f5135bb
IOUTest fix
nyomanjyotisa Jan 14, 2025
a03684d
IOUTest property shorthand
nyomanjyotisa Jan 14, 2025
2a70a0c
DotIndicatorMessage adjustment
nyomanjyotisa Jan 15, 2025
26af42a
Merge branch 'main' into issue-50507-2
nyomanjyotisa Jan 20, 2025
3e5e2c6
Merge branch 'main' into issue-50507-2
nyomanjyotisa Jan 20, 2025
ab6b967
ESLint fix
nyomanjyotisa Jan 20, 2025
8390821
Update trackExpense function call
nyomanjyotisa Jan 20, 2025
fef81e0
Merge branch 'main' into issue-50507-2
nyomanjyotisa Jan 20, 2025
9e27e13
ESLint fix
nyomanjyotisa Jan 20, 2025
349aaa7
Prettier
nyomanjyotisa Jan 20, 2025
3ae692a
ESLint fix
nyomanjyotisa Jan 21, 2025
5f269b0
minor fix
nyomanjyotisa Jan 22, 2025
6be8ac2
Merge branch 'main' into issue-50507-2
nyomanjyotisa Jan 31, 2025
f87e2d1
ESLint fix
nyomanjyotisa Jan 31, 2025
29f63b9
Merge branch 'main' into issue-50507-2
nyomanjyotisa Feb 3, 2025
e01aea7
Track expense fix
nyomanjyotisa Feb 11, 2025
683109a
Merge branch 'main' into issue-50507-2
nyomanjyotisa Feb 11, 2025
198b140
ESLint fix
nyomanjyotisa Feb 11, 2025
4b4f359
Merge branch 'main' into issue-50507-2
nyomanjyotisa Feb 13, 2025
5410ddc
Track expense fix
nyomanjyotisa Feb 13, 2025
19727ce
Merge branch 'main' into issue-50507-2
nyomanjyotisa Feb 14, 2025
df5f915
Merge branch 'main' into issue-50507-2
nyomanjyotisa Feb 24, 2025
d8c4b58
Merge branch 'main' into issue-50507-2
nyomanjyotisa Feb 26, 2025
7460c49
Merge branch 'main' into issue-50507-2
nyomanjyotisa Mar 12, 2025
9f04b63
Merge branch 'main' into issue-50507-2
nyomanjyotisa Mar 21, 2025
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
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,12 @@ const CONST = {
BBA: 'BBA',
PBA: 'PBA',
},
ACTION_PARAMS: {
START_SPLIT_BILL: 'startSplitBill',
TRACK_EXPENSE: 'trackExpense',
MONEY_REQUEST: 'moneyRequest',
REPLACE_RECEIPT: 'replaceReceipt',
},
},

GROWL: {
Expand Down Expand Up @@ -6878,6 +6884,7 @@ type IOUType = ValueOf<typeof CONST.IOU.TYPE>;
type IOUAction = ValueOf<typeof CONST.IOU.ACTION>;
type IOURequestType = ValueOf<typeof CONST.IOU.REQUEST_TYPE>;
type FeedbackSurveyOptionID = ValueOf<Pick<ValueOf<typeof CONST.FEEDBACK_SURVEY_OPTIONS>, 'ID'>>;
type IOUActionParams = ValueOf<typeof CONST.IOU.ACTION_PARAMS>;

type SubscriptionType = ValueOf<typeof CONST.SUBSCRIPTION.TYPE>;
type CancellationType = ValueOf<typeof CONST.CANCELLATION_TYPE>;
Expand All @@ -6894,6 +6901,7 @@ export type {
CancellationType,
OnboardingInvite,
OnboardingAccounting,
IOUActionParams,
};

export default CONST;
60 changes: 44 additions & 16 deletions src/components/DotIndicatorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/* eslint-disable react/no-array-index-key */
import type {ReactElement} from 'react';
import React from 'react';
import React, {useState} from 'react';
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {isReceiptError} from '@libs/ErrorUtils';
import fileDownload from '@libs/fileDownload';
import {translateLocal} from '@libs/Localize';
import handleRetryPress from '@libs/ReceiptUploadRetryHandler';
import type {ReceiptError} from '@src/types/onyx/Transaction';
import ConfirmModal from './ConfirmModal';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import Text from './Text';
Expand All @@ -33,12 +36,18 @@ type DotIndicatorMessageProps = {

/** Additional styles to apply to the text */
textStyles?: StyleProp<TextStyle>;

/** A function to dismiss error */
dismissError?: () => void;
};

function DotIndicatorMessage({messages = {}, style, type, textStyles}: DotIndicatorMessageProps) {
function DotIndicatorMessage({messages = {}, style, type, textStyles, dismissError = () => {}}: DotIndicatorMessageProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();

const [shouldShowErrorModal, setShouldShowErrorModal] = useState(false);

if (Object.keys(messages).length === 0) {
return null;
Expand All @@ -57,22 +66,41 @@ function DotIndicatorMessage({messages = {}, style, type, textStyles}: DotIndica
const renderMessage = (message: string | ReceiptError | ReactElement, index: number) => {
if (isReceiptError(message)) {
return (
<Text
key={index}
style={styles.offlineFeedback.text}
>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{translateLocal('iou.error.receiptFailureMessage')}</Text>
<TextLink
style={[StyleUtils.getDotIndicatorTextStyles(), styles.link]}
onPress={() => {
fileDownload(message.source, message.filename);
}}
<>
<Text
key={index}
style={styles.offlineFeedback.text}
>
{translateLocal('iou.error.saveFileMessage')}
</TextLink>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{translateLocal('iou.error.receiptFailureMessage')}</Text>
<TextLink
style={[StyleUtils.getDotIndicatorTextStyles(), styles.link]}
onPress={() => handleRetryPress(message, dismissError, setShouldShowErrorModal)}
>
{translateLocal('iou.error.tryAgainMessage')}
</TextLink>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{translateLocal('common.or')}</Text>
<TextLink
style={[StyleUtils.getDotIndicatorTextStyles(), styles.link]}
onPress={() => {
fileDownload(message.source, message.filename).finally(() => dismissError());
}}
>
{translateLocal('iou.error.saveFileMessage')}
</TextLink>

<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{translateLocal('iou.error.loseFileMessage')}</Text>
</Text>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{translateLocal('iou.error.uploadLaterMessage')}</Text>
</Text>

<ConfirmModal
isVisible={shouldShowErrorModal}
onConfirm={() => {
setShouldShowErrorModal(false);
}}
prompt={translate('common.genericErrorMessage')}
confirmText={translate('common.ok')}
shouldShowCancelButton={false}
/>
</>
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/components/ErrorMessageRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ type ErrorMessageRowProps = {

/** Whether we can dismiss the error message */
canDismissError?: boolean;

/** A function to dismiss error */
dismissError?: () => void;
};

function ErrorMessageRow({errors, errorRowStyles, onClose, canDismissError = true}: ErrorMessageRowProps) {
function ErrorMessageRow({errors, errorRowStyles, onClose, canDismissError = true, dismissError}: ErrorMessageRowProps) {
// Some errors have a null message. This is used to apply opacity only and to avoid showing redundant messages.
const errorEntries = Object.entries(errors ?? {});
const filteredErrorEntries = errorEntries.filter((errorEntry): errorEntry is [string, string | ReceiptError] => errorEntry[1] !== null);
Expand All @@ -34,6 +37,7 @@ function ErrorMessageRow({errors, errorRowStyles, onClose, canDismissError = tru
onClose={onClose}
containerStyles={errorRowStyles}
canDismiss={canDismissError}
dismissError={dismissError}
/>
) : null;
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/MessagesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ type MessagesRowProps = {

/** Whether we can dismiss the messages */
canDismiss?: boolean;

/** A function to dismiss error */
dismissError?: () => void;
};

function MessagesRow({messages = {}, type, onClose = () => {}, containerStyles, canDismiss = true}: MessagesRowProps) {
function MessagesRow({messages = {}, type, onClose = () => {}, containerStyles, canDismiss = true, dismissError = () => {}}: MessagesRowProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -42,6 +45,7 @@ function MessagesRow({messages = {}, type, onClose = () => {}, containerStyles,
return (
<View style={[styles.flexRow, styles.alignItemsCenter, containerStyles]}>
<DotIndicatorMessage
dismissError={dismissError}
style={styles.flex1}
messages={messages}
type={type}
Expand Down
6 changes: 6 additions & 0 deletions src/components/OfflineWithFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type OfflineWithFeedbackProps = ChildrenProps & {

/** Whether we should force opacity */
shouldForceOpacity?: boolean;

/** A function to dismiss error */
dismissError?: () => void;
};

type StrikethroughProps = Partial<ChildrenProps> & {style: AllStyles[]};
Expand All @@ -82,6 +85,7 @@ function OfflineWithFeedback({
style,
shouldDisplayErrorAbove = false,
shouldForceOpacity = false,
dismissError = () => {},
...rest
}: OfflineWithFeedbackProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -138,6 +142,7 @@ function OfflineWithFeedback({
errorRowStyles={errorRowStyles}
onClose={onClose}
canDismissError={canDismissError}
dismissError={dismissError}
/>
)}
{!hideChildren && (
Expand All @@ -154,6 +159,7 @@ function OfflineWithFeedback({
errorRowStyles={errorRowStyles}
onClose={onClose}
canDismissError={canDismissError}
dismissError={dismissError}
/>
)}
</View>
Expand Down
82 changes: 58 additions & 24 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, {useCallback, useMemo} from 'react';
import mapValues from 'lodash/mapValues';
import React, {useCallback, useMemo, useState} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import ConfirmModal from '@components/ConfirmModal';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItem from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
Expand All @@ -22,6 +24,7 @@ import useViolations from '@hooks/useViolations';
import type {ViolationField} from '@hooks/useViolations';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import DistanceRequestUtils from '@libs/DistanceRequestUtils';
import {isReceiptError} from '@libs/ErrorUtils';
import {hasEnabledOptions} from '@libs/OptionsListUtils';
import {getTagLists, hasDependentTags, isTaxTrackingEnabled} from '@libs/PolicyUtils';
import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils';
Expand Down Expand Up @@ -477,6 +480,35 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
);
});

const [showConfirmDismissReceiptError, setShowConfirmDismissReceiptError] = useState(false);

const dismissReceiptError = useCallback(() => {
if (!report?.reportID) {
return;
}
if (transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
if (chatReport?.reportID && getAddWorkspaceRoomOrChatReportErrors(chatReport)) {
navigateToConciergeChatAndDeleteReport(chatReport.reportID, true, true);
return;
}
if (parentReportAction) {
cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, report.reportID, true);
return;
}
}
if (!transaction?.transactionID) {
if (!linkedTransactionID) {
return;
}
clearError(linkedTransactionID);
clearAllRelatedReportActionErrors(report.reportID, parentReportAction);
return;
}
revert(transaction?.transactionID ?? linkedTransactionID, getLastModifiedExpense(report?.reportID));
clearError(transaction.transactionID);
clearAllRelatedReportActionErrors(report.reportID, parentReportAction);
}, [transaction, chatReport, parentReportAction, linkedTransactionID, report?.reportID]);

return (
<View style={styles.pRelative}>
{shouldShowAnimatedBackground && <AnimatedEmptyStateBackground />}
Expand All @@ -499,31 +531,17 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
return;
}

if (transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
if (chatReport?.reportID && getAddWorkspaceRoomOrChatReportErrors(chatReport)) {
navigateToConciergeChatAndDeleteReport(chatReport.reportID, true, true);
return;
}
if (parentReportAction) {
cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true);
return;
}
}
if (!report?.reportID) {
return;
}
if (!transaction?.transactionID) {
if (!linkedTransactionID) {
return;
}
clearError(linkedTransactionID);
clearAllRelatedReportActionErrors(report.reportID, parentReportAction);
return;
const errorEntries = Object.entries(errors ?? {});
const errorMessages = mapValues(Object.fromEntries(errorEntries), (error) => error);
const hasReceiptError = Object.values(errorMessages).some((error) => isReceiptError(error));

if (hasReceiptError) {
setShowConfirmDismissReceiptError(true);
} else {
dismissReceiptError();
}
revert(transaction?.transactionID ?? linkedTransactionID, getLastModifiedExpense(report?.reportID));
clearError(transaction.transactionID);
clearAllRelatedReportActionErrors(report.reportID, parentReportAction);
}}
dismissError={dismissReceiptError}
>
{hasReceipt && (
<View style={styles.moneyRequestViewImage}>
Expand Down Expand Up @@ -781,6 +799,22 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
</View>
)}
</>
<ConfirmModal
isVisible={showConfirmDismissReceiptError}
onConfirm={() => {
dismissReceiptError();
setShowConfirmDismissReceiptError(false);
}}
onCancel={() => {
setShowConfirmDismissReceiptError(false);
}}
title={translate('iou.dismissReceiptError')}
prompt={translate('iou.dismissReceiptErrorConfirmation')}
confirmText={translate('common.dismiss')}
cancelText={translate('common.cancel')}
shouldShowCancelButton
danger
/>
</View>
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,10 +1033,10 @@ const translations = {
genericHoldExpenseFailureMessage: 'Unexpected error holding this expense. Please try again later.',
genericUnholdExpenseFailureMessage: 'Unexpected error taking this expense off hold. Please try again later.',
receiptDeleteFailureError: 'Unexpected error deleting this receipt. Please try again later.',
receiptFailureMessage: "The receipt didn't upload. ",
// eslint-disable-next-line rulesdir/use-periods-for-error-messages
saveFileMessage: 'Download the file ',
loseFileMessage: 'or dismiss this error and lose it.',
receiptFailureMessage: 'There was an error uploading your receipt. Please ',
tryAgainMessage: 'try again ',
saveFileMessage: ' save the receipt',
uploadLaterMessage: ' to upload later.',
genericDeleteFailureMessage: 'Unexpected error deleting this expense. Please try again later.',
genericEditFailureMessage: 'Unexpected error editing this expense. Please try again later.',
genericSmartscanFailureMessage: 'Transaction is missing fields.',
Expand All @@ -1050,6 +1050,8 @@ const translations = {
invalidSubrateLength: 'There must be at least one subrate.',
invalidRate: 'Rate not valid for this workspace. Please select an available rate from the workspace.',
},
dismissReceiptError: 'Dismiss error',
dismissReceiptErrorConfirmation: 'Heads up! Dismissing this error will remove your uploaded receipt entirely. Are you sure?',
waitingOnEnabledWallet: ({submitterDisplayName}: WaitingOnBankAccountParams) => `started settling up. Payment is on hold until ${submitterDisplayName} enables their wallet.`,
enableWallet: 'Enable wallet',
hold: 'Hold',
Expand Down
10 changes: 6 additions & 4 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1030,10 +1030,10 @@ const translations = {
genericCreateFailureMessage: 'Error inesperado al enviar este gasto. Por favor, inténtalo más tarde.',
genericCreateInvoiceFailureMessage: 'Error inesperado al enviar la factura. Por favor, inténtalo de nuevo más tarde.',
receiptDeleteFailureError: 'Error inesperado al borrar este recibo. Por favor, vuelve a intentarlo más tarde.',
receiptFailureMessage: 'El recibo no se subió. ',
// eslint-disable-next-line rulesdir/use-periods-for-error-messages
saveFileMessage: 'Guarda el archivo ',
loseFileMessage: 'o descarta este error y piérdelo.',
receiptFailureMessage: 'Hubo un error al cargar tu recibo. Por favor, ',
tryAgainMessage: 'inténtalo de nuevo ',
saveFileMessage: ' guarda el recibo',
uploadLaterMessage: ' para cargarlo más tarde.',
genericDeleteFailureMessage: 'Error inesperado al eliminar este gasto. Por favor, inténtalo más tarde.',
genericEditFailureMessage: 'Error inesperado al editar este gasto. Por favor, inténtalo más tarde.',
genericSmartscanFailureMessage: 'La transacción tiene campos vacíos.',
Expand All @@ -1047,6 +1047,8 @@ const translations = {
invalidSubrateLength: 'Debe haber al menos una subtasa.',
invalidRate: 'Tasa no válida para este espacio de trabajo. Por favor, selecciona una tasa disponible en el espacio de trabajo.',
},
dismissReceiptError: 'Descartar error',
dismissReceiptErrorConfirmation: '¡Atención! Descartar este error eliminará completamente tu recibo cargado. ¿Estás seguro?',
waitingOnEnabledWallet: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inició el pago, pero no se procesará hasta que ${submitterDisplayName} active su billetera`,
enableWallet: 'Habilitar billetera',
holdExpense: 'Retener gasto',
Expand Down
Loading