Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c3a6979
Add retry button and logic
rinej Aug 31, 2026
f3738be
Merge branch 'main' into receipt-upload-retry-button
rinej Sep 7, 2026
096c7fe
feat: rebuild receipt retry payload from Onyx
rinej Sep 8, 2026
fee2262
test: add tests for retry logic
rinej Sep 8, 2026
25a2515
chore: knip fixes
rinej Sep 8, 2026
533c76a
chore: adjust comments
rinej Sep 8, 2026
1895eda
fix: fix two receipt retry bugs found on device
rinej Sep 14, 2026
69bf7c8
tests: adjust units
rinej Sep 14, 2026
f9367e2
Merge branch 'main' into receipt-upload-retry-button
rinej Sep 14, 2026
629ba4e
Merge branch 'main' into receipt-upload-retry-button
rinej Sep 14, 2026
4bf4a6d
chore: types fixes after main merge
rinej Sep 14, 2026
463e657
chore: review comments adjustment
rinej Sep 14, 2026
668eeed
fix: stop retry from double counting the expense on its report
rinej Sep 15, 2026
ff62592
fix: preserve the amount sign when rebuilding a retry, adjust styles
rinej Sep 15, 2026
be7fc2c
Merge branch 'main' into receipt-upload-retry-button
rinej Sep 15, 2026
80e62b2
Merge branch 'main' into receipt-upload-retry-button
rinej Sep 16, 2026
5f8e9b9
Reduce failed-receipt row to Retry and Save, drop the duplicate error…
adhorodyski Sep 17, 2026
ffe4f42
Merge branch 'Expensify:main' into receipt-upload-retry-button
adhorodyski Sep 17, 2026
2e458ff
Shorten the failed-receipt upload error message
adhorodyski Sep 18, 2026
05ee28b
Merge remote-tracking branch 'upstream/main' into receipt-upload-retr…
adhorodyski Sep 18, 2026
c67acc7
Pass isVendorMatchingBetaEnabled instead of betas to the receipt retr…
adhorodyski Sep 18, 2026
0ad227b
fix: keep the retryable receipt error, limit Try again to native, add…
BartekObudzinski Sep 23, 2026
e088ac4
fix: use the save-only receipt error copy suggested in review
BartekObudzinski Sep 24, 2026
8674792
Add generated translations for receipt upload retry copy
BartekObudzinski Sep 24, 2026
ee6b5d8
fix: clear the receipt error only after the retry is dispatched, rest…
BartekObudzinski Sep 24, 2026
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
38 changes: 20 additions & 18 deletions src/components/DotIndicatorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ type DotIndicatorMessageProps = {
style?: StyleProp<ViewStyle>;

textStyles?: StyleProp<TextStyle>;

// Unused here, but OfflineWithFeedback still passes it to every error row.
// eslint-disable-next-line react/no-unused-prop-types

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to change the props declaration, do let me know if we should rather make changes uptree.

dismissError?: () => void;

onRetryReceiptUpload?: () => void;
};

function DotIndicatorMessage({messages = {}, style, type, textStyles, dismissError = () => {}}: DotIndicatorMessageProps) {
function DotIndicatorMessage({messages = {}, style, type, textStyles, onRetryReceiptUpload}: DotIndicatorMessageProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const expensifyIcons = useMemoizedLazyExpensifyIcons(['DotIndicator']);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['ArrowCircleClockwise', 'DotIndicator', 'Download']);
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {shouldUseNarrowLayout, isSmallScreenWidth, isInNarrowPaneModal} = useResponsiveLayout();

Expand Down Expand Up @@ -119,37 +124,34 @@ function DotIndicatorMessage({messages = {}, style, type, textStyles, dismissErr
const isStackedLayout = !(isInNarrowPaneModal && !isSmallScreenWidth);
const messageRow = (
<View style={[styles.dotIndicatorMessage, isStackedLayout && styles.alignItemsStart, styles.flex1]}>
<View style={styles.offlineFeedbackErrorDot}>
<Icon
src={expensifyIcons.DotIndicator}
fill={isErrorMessage ? theme.danger : theme.success}
/>
</View>
<Text
style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage), textStyles, styles.flex1]}
accessibilityRole={isErrorMessage ? CONST.ROLE.ALERT : undefined}
accessibilityLiveRegion={isErrorMessage ? 'assertive' : undefined}
>
{translate('iou.error.receiptUploadFailedMessage')}
{translate(onRetryReceiptUpload ? 'iou.error.receiptUploadFailedMessage' : 'iou.error.receiptUploadFailedSaveOnlyMessage')}
</Text>
</View>
);
const buttonsRow = (
<View style={[styles.flexRow, styles.gap3]}>
<View style={[styles.flexRow, styles.flexWrap, styles.gap2]}>
{!!onRetryReceiptUpload && (
Comment thread
mountiny marked this conversation as resolved.
<Button
size={CONST.BUTTON_SIZE.SMALL}
onPress={onRetryReceiptUpload}
>
<Button.Icon src={expensifyIcons.ArrowCircleClockwise} />
<Button.Text>{translate('common.tryAgain')}</Button.Text>
</Button>
)}
<Button
size={CONST.BUTTON_SIZE.SMALL}
onPress={() => {
fileDownload(translate, receiptError.source, receiptError.filename);
}}
>
<Button.Text>{translate('iou.error.saveReceipt')}</Button.Text>
</Button>
<Button
variant={CONST.BUTTON_VARIANT.DANGER}
size={CONST.BUTTON_SIZE.SMALL}
onPress={dismissError}
>
<Button.Text>{translate('iou.deleteExpense', {count: 1})}</Button.Text>
<Button.Icon src={expensifyIcons.Download} />
<Button.Text>{translate('common.save')}</Button.Text>
</Button>
</View>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/ErrorMessageRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ type ErrorMessageRowProps = {
onDismiss?: () => void;

dismissError?: () => void;

onRetryReceiptUpload?: () => void;
};

function ErrorMessageRow({errors, errorRowStyles, onDismiss, dismissError, errorRowTextStyles}: ErrorMessageRowProps) {
function ErrorMessageRow({errors, errorRowStyles, onDismiss, dismissError, errorRowTextStyles, onRetryReceiptUpload}: 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 | OnyxCommon.TranslationKeyError] => errorEntry[1] !== null);
Expand All @@ -35,6 +37,7 @@ function ErrorMessageRow({errors, errorRowStyles, onDismiss, dismissError, error
containerStyles={errorRowStyles}
errorTextStyles={errorRowTextStyles}
dismissError={dismissError}
onRetryReceiptUpload={onRetryReceiptUpload}
/>
) : null;
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/MessagesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ type MessagesRowProps = {
containerStyles?: StyleProp<ViewStyle>;
errorTextStyles?: StyleProp<TextStyle>;
dismissError?: () => void;

onRetryReceiptUpload?: () => void;
};

function MessagesRow({messages = {}, type, onDismiss, containerStyles, dismissError = () => {}, errorTextStyles}: MessagesRowProps) {
function MessagesRow({messages = {}, type, onDismiss, containerStyles, dismissError = () => {}, errorTextStyles, onRetryReceiptUpload}: MessagesRowProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -53,6 +55,7 @@ function MessagesRow({messages = {}, type, onDismiss, containerStyles, dismissEr
<View style={[styles.flexRow, styles.alignItemsCenter, containerStyles]}>
<DotIndicatorMessage
dismissError={dismissError}
onRetryReceiptUpload={onRetryReceiptUpload}
style={styles.flex1}
textStyles={errorTextStyles}
messages={messages}
Expand Down
5 changes: 5 additions & 0 deletions src/components/OfflineWithFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type OfflineWithFeedbackProps = Partial<ChildrenProps> & {

shouldForceOpacity?: boolean;
dismissError?: () => void;

onRetryReceiptUpload?: () => void;
};

type StrikethroughProps = Partial<ChildrenProps> & {style: AllStyles[]};
Expand All @@ -81,6 +83,7 @@ function OfflineWithFeedback({
shouldDisplayErrorAbove = false,
shouldForceOpacity = false,
dismissError = () => {},
onRetryReceiptUpload,
errorRowTextStyles,
...restProps
}: OfflineWithFeedbackProps) {
Expand Down Expand Up @@ -142,6 +145,7 @@ function OfflineWithFeedback({
onDismiss={onDismiss}
errorRowTextStyles={errorRowTextStyles}
dismissError={dismissError}
onRetryReceiptUpload={onRetryReceiptUpload}
/>
)}
{hasChildren && !hideChildren && (
Expand All @@ -159,6 +163,7 @@ function OfflineWithFeedback({
errorRowTextStyles={errorRowTextStyles}
onDismiss={onDismiss}
dismissError={dismissError}
onRetryReceiptUpload={onRetryReceiptUpload}
/>
)}
</View>
Expand Down
51 changes: 47 additions & 4 deletions src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ import {getBrokenConnectionUrlToFixPersonalCard} from '@libs/CardUtils';
import {hasHoverSupport} from '@libs/DeviceCapabilities';
import {getMicroSecondOnyxErrorObject, getMicroSecondOnyxErrorWithTranslationKey, isReceiptError} from '@libs/ErrorUtils';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import Log from '@libs/Log';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import {isTrackOnboardingChoice} from '@libs/OnboardingUtils';
import {isGroupPolicyByType} from '@libs/PolicyUtils';
import retryReceiptUpload, {canBuildRetryPayload} from '@libs/ReceiptUploadRetryHandler';
import type {ReceiptRetryContext} from '@libs/ReceiptUploadRetryHandler/types';
import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils';
import {getOriginalMessage, isMoneyRequestAction, wasActionTakenByCurrentUser} from '@libs/ReportActionsUtils';
import {isMarkAsCashActionForTransaction} from '@libs/ReportPrimaryActionUtils';
Expand Down Expand Up @@ -70,15 +74,15 @@ import variables from '@styles/variables';

import {clearAllRelatedReportActionErrors} from '@userActions/ClearReportActionErrors';
import {cleanUpMoneyRequest} from '@userActions/IOU/DeleteMoneyRequest';
import {replaceReceipt} from '@userActions/IOU/Receipt';
import {clearReceiptUploadError, replaceReceipt} from '@userActions/IOU/Receipt';
import {addAttachmentWithComment, navigateToConciergeChatAndDeleteReport, setDeleteTransactionNavigateBackUrl} from '@userActions/Report';
import {clearError, getLastModifiedExpense, revert} from '@userActions/Transaction';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import type * as OnyxTypes from '@src/types/onyx';
import type {TransactionPendingFieldsKey} from '@src/types/onyx/Transaction';
import type {ReceiptError, TransactionPendingFieldsKey} from '@src/types/onyx/Transaction';
import type {FileObject} from '@src/types/utils/Attachment';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

Expand Down Expand Up @@ -137,8 +141,8 @@ function MoneyRequestReceiptView({
hasParentPendingAction = false,
}: MoneyRequestReceiptViewProps) {
const styles = useThemeStyles();
const {translate, dateFnsLocale} = useLocalize();
const {isBetaEnabledOrUnknown} = usePermissions();
const {translate, dateFnsLocale, formatPhoneNumber} = useLocalize();
const {isBetaEnabled, isBetaEnabledOrUnknown} = usePermissions();
const isVendorMatchingBetaEnabled = isBetaEnabledOrUnknown(CONST.BETAS.VENDOR_MATCHING);
const {convertToDisplayString, getCurrencyDecimals} = useCurrencyListActions();
const {environmentURL} = useEnvironment();
Expand Down Expand Up @@ -418,6 +422,44 @@ function MoneyRequestReceiptView({

const {showConfirmModal} = useConfirmModal();

const retryableReceiptError = Object.values(errors ?? {}).find((error): error is ReceiptError => isReceiptError(error));
const receiptRetryContext: ReceiptRetryContext | undefined = retryableReceiptError
? {
receiptError: retryableReceiptError,
transaction,
iouReport: moneyRequestReport,
iouActionID: parentReportAction?.reportActionID,
transactionThreadReportID: report?.reportID,
policyParams: {policy, policyCategories, policyTagList},
isVendorMatchingBetaEnabled,
rules,
conciergeReportID,
isSelfTourViewed: !!isSelfTourViewed,
isASAPSubmitBetaEnabled: isBetaEnabled(CONST.BETAS.ASAP_SUBMIT),
isTrackIntentUser: isTrackOnboardingChoice(introSelected?.choice),
delegateAccountID,
formatPhoneNumber,
getCurrencyDecimals,
}
: undefined;

const canRetryUpload = !!receiptRetryContext && canBuildRetryPayload(receiptRetryContext);

const retryReceiptUploadAndClearError = () => {
if (!receiptRetryContext) {
return;
}

retryReceiptUpload(receiptRetryContext, () =>
clearReceiptUploadError({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we consider clearing the receipt error only after requestMoney() succeeds? I'm wondering if clearing it in onBeforeDispatch could leave the user without the retry option if the dispatch fails synchronously. Is that a possible edge case here? Thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Now the error is cleared only after requestMoney() is called. If building the request throws, the receipt error stays and the user still has Try again and Save. I added a test for that.

If the retry fails on the server, failureData writes a new receipt error, so Try again comes back anyway.

transactionID: transaction?.transactionID,
reportID: parentReportAction?.reportID ?? report?.reportID,
reportActionID: parentReportAction?.reportActionID,
reportIDWithCreationError: report?.reportID,
}),
).catch((error: unknown) => Log.alert('[ReceiptRetry] Retry failed unexpectedly', {error}));
};

const transactionAndReportActionErrors = useMemo(
() => ({
...transaction?.errors,
Expand Down Expand Up @@ -662,6 +704,7 @@ function MoneyRequestReceiptView({
});
}}
dismissError={dismissReceiptError}
onRetryReceiptUpload={canRetryUpload ? retryReceiptUploadAndClearError : undefined}
style={[shouldShowAuditMessage ? styles.mt3 : styles.mv3, !showReceiptErrorWithEmptyState && styles.flex1]}
contentContainerStyle={styles.flex1}
>
Expand Down
3 changes: 2 additions & 1 deletion src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ const translations: TranslationDeepObject<typeof en> = {
receiptFailureMessage:
'<rbr>Beim Hochladen deiner Quittung ist ein Fehler aufgetreten. Bitte <a href="download">speichere die Quittung</a> und <a href="retry">versuche es später erneut</a>.</rbr>',
receiptFailureMessageShort: 'Beim Hochladen Ihres Belegs ist ein Fehler aufgetreten.',
receiptUploadFailedMessage: 'Beleg-Upload fehlgeschlagen. Speichere den Beleg oder lösche die Ausgabe und verliere sie.',
receiptUploadFailedMessage: 'Upload fehlgeschlagen. Versuchen Sie es erneut oder speichern Sie es für später.',
saveReceipt: 'Beleg speichern',
genericDeleteFailureMessage: 'Unerwarteter Fehler beim Löschen dieses Belegs. Bitte versuche es später erneut.',
genericEditFailureMessage: 'Unerwarteter Fehler beim Bearbeiten dieser Ausgabe. Bitte versuche es später noch einmal.',
Expand Down Expand Up @@ -1656,6 +1656,7 @@ const translations: TranslationDeepObject<typeof en> = {
'Diese Berichte konnten nicht als erledigt markiert werden. Prüfen Sie, dass Ausgaben nicht zurückgehalten oder ausstehend sind, und versuchen Sie es dann erneut.',
stitchOdometerImagesFailed: 'Kilometerzählerbilder konnten nicht zusammengeführt werden. Bitte versuchen Sie es später noch einmal.',
failedToSaveOdometerDraft: 'Dein Kilometerzähler-Entwurf konnte nicht gespeichert werden. Bitte versuche es erneut.',
receiptUploadFailedSaveOnlyMessage: 'Upload fehlgeschlagen. Speichern Sie Ihre Quittung, um sie zu behalten.',
},
dismissReceiptError: 'Fehler ausblenden',
dismissReceiptErrorConfirmation: 'Achtung! Wenn du diesen Fehler schließt, wird deine hochgeladene Quittung vollständig entfernt. Bist du sicher?',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ const translations: TranslationDeepObject<typeof en> = {
receiptFailureMessage:
'<rbr>Προέκυψε σφάλμα κατά τη μεταφόρτωση της απόδειξής σας. Παρακαλούμε <a href="download">αποθηκεύστε την απόδειξη</a> και <a href="retry">δοκιμάστε ξανά</a> αργότερα.</rbr>',
receiptFailureMessageShort: 'Παρουσιάστηκε σφάλμα κατά τη μεταφόρτωση της απόδειξής σας.',
receiptUploadFailedMessage: 'Η αποστολή της απόδειξης απέτυχε. Αποθηκεύστε την απόδειξη ή διαγράψτε την δαπάνη και χάστε την.',
receiptUploadFailedMessage: 'Η μεταφόρτωση απέτυχε. Δοκιμάστε ξανά ή αποθηκεύστε για αργότερα.',
saveReceipt: 'Αποθήκευση απόδειξης',
genericDeleteFailureMessage: 'Παρουσιάστηκε απρόσμενο σφάλμα κατά τη διαγραφή αυτής της δαπάνης. Παρακαλούμε δοκιμάστε ξανά αργότερα.',
genericEditFailureMessage: 'Παρουσιάστηκε απροσδόκητο σφάλμα κατά την επεξεργασία αυτής της δαπάνης. Παρακαλούμε δοκιμάστε ξανά αργότερα.',
Expand All @@ -1712,6 +1712,7 @@ const translations: TranslationDeepObject<typeof en> = {
endDateSameAsStartDate: 'Η ημερομηνία λήξης δεν μπορεί να είναι ίδια με την ημερομηνία έναρξης',
manySplitsProvided: `Ο μέγιστος επιτρεπόμενος αριθμός διαχωρισμών είναι ${CONST.IOU.SPLITS_LIMIT}.`,
dateRangeExceedsMaxDays: `Το εύρος ημερομηνιών δεν μπορεί να υπερβαίνει τις ${CONST.IOU.SPLITS_LIMIT} ημέρες.`,
receiptUploadFailedSaveOnlyMessage: 'Η αποστολή απέτυχε. Αποθηκεύστε την απόδειξή σας για να τη διατηρήσετε.',
},
dismissReceiptError: 'Απόρριψη σφάλματος',
dismissReceiptErrorConfirmation: 'Προσοχή! Αν απορρίψετε αυτό το σφάλμα, η ανεβασμένη απόδειξή σας θα διαγραφεί πλήρως. Είστε βέβαιοι;',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,8 @@ const translations = {
receiptDeleteFailureError: 'Unexpected error deleting this receipt. Please try again later.',
receiptFailureMessage: '<rbr>There was an error uploading your receipt. Please <a href="download">save the receipt</a> and <a href="retry">try again</a> later.</rbr>',
receiptFailureMessageShort: 'There was an error uploading your receipt.',
receiptUploadFailedMessage: 'Receipt upload failed. Save the receipt, or delete the expense and lose it.',
receiptUploadFailedMessage: 'Upload failed. Try again or save for later.',
receiptUploadFailedSaveOnlyMessage: 'Upload failed. Save your receipt to keep it.',
saveReceipt: 'Save receipt',
genericDeleteFailureMessage: 'Unexpected error deleting this expense. Please try again later.',
genericEditFailureMessage: 'Unexpected error editing this expense. Please try again later.',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ const translations: TranslationDeepObject<typeof en> = {
receiptDeleteFailureError: 'Error inesperado al borrar este recibo. Por favor, vuelve a intentarlo más tarde.',
receiptFailureMessage: '<rbr>Hubo un error al cargar tu recibo. Por favor, <a href="download">guarda el recibo</a> e <a href="retry">inténtalo de nuevo</a> más tarde.</rbr>',
receiptFailureMessageShort: 'Hubo un error al cargar tu recibo.',
receiptUploadFailedMessage: 'Error al subir el recibo. Guarda el recibo, o elimina el gasto y piérdelo.',
receiptUploadFailedMessage: 'La carga ha fallado. Inténtalo de nuevo o guárdalo para más tarde.',
saveReceipt: 'Guardar recibo',
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.',
Expand All @@ -1653,6 +1653,7 @@ const translations: TranslationDeepObject<typeof en> = {
endDateSameAsStartDate: 'La fecha de finalización no puede ser la misma que la fecha de inicio',
manySplitsProvided: `El número máximo de divisiones permitidas es ${CONST.IOU.SPLITS_LIMIT}.`,
dateRangeExceedsMaxDays: `El rango de fechas no puede exceder los ${CONST.IOU.SPLITS_LIMIT} días.`,
receiptUploadFailedSaveOnlyMessage: 'La carga ha fallado. Guarda tu recibo para conservarlo.',
},
dismissReceiptError: 'Descartar error',
dismissReceiptErrorConfirmation: '¡Atención! Descartar este error eliminará completamente tu recibo cargado. ¿Estás seguro?',
Expand Down
Loading
Loading