Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f1ea9a8
Add Translate to receipts behind the receiptTranslation beta
Krishna2323 Oct 28, 2026
4e9e728
Add receipt translation keys to Onyx export buckets
Krishna2323 Oct 29, 2026
0f2fb85
Match receipt translation design for scanning and card
Krishna2323 Oct 29, 2026
ab67785
Use exact Figma spacing for the translated receipt card
Krishna2323 Oct 29, 2026
e1f69ab
Center the translated receipt card in the modal
Krishna2323 Oct 29, 2026
d92a548
Show receipt translation errors in a growl
Krishna2323 Oct 29, 2026
319c0e5
Use the translate icon for receipt translation
Krishna2323 Oct 29, 2026
4f69f21
Match receipt translation to the backend shape and keep the disclaime…
Krishna2323 Oct 30, 2026
a5111bf
Match receipt translation to the backend shape and keep the disclaime…
Krishna2323 Oct 30, 2026
5dd37ae
Merge branch 'Expensify:main' into krishna2323/105053-receipt-translate
Krishna2323 Oct 31, 2026
a55c529
Merge remote-tracking branch 'origin/krishna2323/105053-receipt-trans…
Krishna2323 Nov 2, 2026
12a1728
Merge remote-tracking branch 'origin/main' into krishna2323/105053-re…
Krishna2323 Nov 5, 2026
327843d
Merge branch 'main' of https://github.com/Expensify/App into krishna2…
Krishna2323 Nov 5, 2026
5e8c611
Merge branch 'main' of https://github.com/Expensify/App into krishna2…
Krishna2323 Nov 6, 2026
34ef69f
Match receipt IDs as strings when showing a saved translation
Krishna2323 Nov 7, 2026
1cc6d6f
Hide receipt Translate while the receipt is scanning
Krishna2323 Nov 7, 2026
8d820e0
Revert Hide receipt Translate while the receipt is scanning
Krishna2323 Nov 7, 2026
f5383aa
Show one spinner while the translating receipt image loads
Krishna2323 Nov 7, 2026
3e02c01
Disable receipt Translate until the receipt finishes uploading
Krishna2323 Nov 7, 2026
7d0df0f
Use the modal bezier curve and a faster pass for the receipt scanning…
Krishna2323 Nov 9, 2026
b2c90c5
Read the receipt translation state from the response instead of Onyx.get
Krishna2323 Nov 9, 2026
1e5a152
update translations.
Krishna2323 Nov 9, 2026
a776179
Merge remote-tracking branch 'upstream/main' into krishna2323/105053-…
Krishna2323 Nov 9, 2026
c0cb932
Track the receipt translation request with a terminal state and allow…
Krishna2323 Nov 9, 2026
1379208
Log failed receipt translation requests and return the Onyx update, m…
Krishna2323 Nov 9, 2026
9937de9
Merge remote-tracking branch 'upstream/main' into krishna2323/105053-…
Krishna2323 Nov 9, 2026
cc1d899
Merge branch 'main' into krishna2323/105053-receipt-translate
Krishna2323 Nov 9, 2026
bfe7501
Show saved translation failures without calling the backend and pause…
Krishna2323 Nov 10, 2026
8e49f00
Wrap long receipt values and hide Translate on distance and per diem …
Krishna2323 Nov 10, 2026
7d14314
Let the receipt modal button row scroll horizontally on narrow screens
Krishna2323 Nov 10, 2026
d2b848b
Hide Translate in the receipt modal and disable it on the thumbnail w…
Krishna2323 Nov 10, 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
1 change: 1 addition & 0 deletions assets/images/translate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/CONST/SENTRY_LABEL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,13 @@ const SENTRY_LABEL = {
NEXT_PAGE_BUTTON: 'Receipt-NextPageButton',
ENLARGE_BUTTON: 'Receipt-EnlargeButton',
ADD_ATTACHMENT_BUTTON: 'Receipt-AddAttachmentButton',
TRANSLATE_BUTTON: 'Receipt-TranslateButton',
},
RECEIPT_MODAL: {
DOWNLOAD_RECEIPT: 'ReceiptModal-DownloadReceipt',
DELETE_RECEIPT: 'ReceiptModal-DeleteReceipt',
TRANSLATE_RECEIPT: 'ReceiptModal-TranslateReceipt',
VIEW_ORIGINAL_RECEIPT: 'ReceiptModal-ViewOriginalReceipt',
CROP: 'ReceiptModal-Crop',
CROP_CANCEL: 'ReceiptModal-CropCancel',
CROP_SAVE: 'ReceiptModal-CropSave',
Expand Down
26 changes: 26 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ const CONST = {
TRAVEL_APPROVAL: 'travelApproval',
FLAT_NAV: 'flatNav',
CATEGORY_VISIBILITY: 'categoryVisibility',
RECEIPT_TRANSLATION: 'receiptTranslation',
SCAN_FLASH_TORCH: 'scanFlashTorch',
NEW_DOT_BILL_PAY: 'newDotBillPay',
HYBRID_WEB: 'hybridWeb',
Expand Down Expand Up @@ -2006,6 +2007,31 @@ const CONST = {

// Elements with this data attribute pause the hover zoom while the pointer is over them
HOVER_ZOOM_EXCLUDED_ELEMENT: 'receipt-hover-zoom-excluded',

TRANSLATION_SCAN_DURATION: 1000,
TRANSLATION_SCAN_LINE_HEIGHT: 8,
TRANSLATION_SCAN_TINT_OPACITY: 0.2,
TRANSLATION_ROW_TYPE: {
HEADING: 'heading',
TEXT: 'text',
LABEL_VALUE: 'labelValue',
ITEM: 'item',
TOTAL: 'total',
DIVIDER: 'divider',
},
TRANSLATION_ROW_ALIGN: {
LEFT: 'left',
CENTER: 'center',
},
TRANSLATION_STATE: {
TRANSLATED: 'translated',
UNREADABLE: 'unreadable',
ALREADY_IN_LANGUAGE: 'alreadyInLanguage',
},
TRANSLATION_REQUEST_STATE: {
LOADING: 'loading',
LOADED: 'loaded',
},
},
RECEIPT_PREVIEW_TOP_BOTTOM_MARGIN: 120,
REPORT: {
Expand Down
7 changes: 7 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ const ONYXKEYS = {
/** Session-scoped loading flags for company cards page and feeds.
* Registered as RAM-only in `setup/index.ts`. */
RAM_ONLY_COMPANY_CARDS_LOADING_STATE: 'companyCardsLoadingState_',
/** Session-scoped translate state for a transaction's receipt.
* Registered as RAM-only in `setup/index.ts`. */
RAM_ONLY_RECEIPT_TRANSLATION_STATE: 'receiptTranslationState_',
/** Session-scoped loading flags for the Expensify Card page, keyed by policyID.
* Registered as RAM-only in `setup/index.ts`. */
RAM_ONLY_EXPENSIFY_CARD_LOADING_STATE: 'expensifyCardLoadingState_',
Expand Down Expand Up @@ -1081,6 +1084,8 @@ const ONYXKEYS = {
TRANSACTION_DRAFT: 'transactionsDraft_',
SKIP_CONFIRMATION: 'skipConfirmation_',
TRANSACTION_BACKUP: 'transactionsBackup_',
/** Receipt translations keyed by transactionID, then by the viewer's locale */
RECEIPT_TRANSLATIONS: 'receiptTranslations_',
SPLIT_TRANSACTION_DRAFT: 'splitTransactionDraft_',
MERGE_TRANSACTION: 'mergeTransaction_',
PRIVATE_NOTES_DRAFT: 'privateNotesDraft_',
Expand Down Expand Up @@ -1690,6 +1695,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.REPORT_UPCOMING_STEPS]: OnyxTypes.ReportUpcomingSteps;
[ONYXKEYS.COLLECTION.RAM_ONLY_REPORT_LOADING_STATE]: OnyxTypes.ReportLoadingState;
[ONYXKEYS.COLLECTION.RAM_ONLY_COMPANY_CARDS_LOADING_STATE]: OnyxTypes.CompanyCardsLoadingState;
[ONYXKEYS.COLLECTION.RAM_ONLY_RECEIPT_TRANSLATION_STATE]: OnyxTypes.ReceiptTranslationState;
[ONYXKEYS.COLLECTION.RAM_ONLY_EXPENSIFY_CARD_LOADING_STATE]: OnyxTypes.ExpensifyCardLoadingState;
[ONYXKEYS.COLLECTION.RAM_ONLY_SEARCH_TAG_FILTERS_PAGINATION]: OnyxTypes.SearchTagFiltersPaginationState;
[ONYXKEYS.COLLECTION.RAM_ONLY_SEARCH_TAG_FILTERS_RESULTS]: OnyxTypes.SearchTagFilterItem[];
Expand All @@ -1715,6 +1721,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.TRANSACTION_DRAFT]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.SKIP_CONFIRMATION]: boolean;
[ONYXKEYS.COLLECTION.TRANSACTION_BACKUP]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.RECEIPT_TRANSLATIONS]: OnyxTypes.ReceiptTranslation;
[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS]: OnyxTypes.TransactionViolations;
[ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.MERGE_TRANSACTION]: OnyxTypes.MergeTransaction;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/chunks/expensify-icons.chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ import ThumbsUp from '@assets/images/thumbs-up.svg';
import TrainCircleSlash from '@assets/images/train-circle-slash.svg';
import Train from '@assets/images/train.svg';
import Transfer from '@assets/images/transfer.svg';
import Translate from '@assets/images/translate.svg';
import Trashcan from '@assets/images/trashcan.svg';
import TreasureChestGreenWithSparkle from '@assets/images/treasure-chest-green-with-sparkle.svg';
import TreasureChest from '@assets/images/treasure-chest.svg';
Expand Down Expand Up @@ -528,6 +529,7 @@ const Expensicons = {
ThumbsUpHourglass,
ThreeDots,
Transfer,
Translate,
Trashcan,
TriNetSquare,
ZenefitsSquare,
Expand Down
150 changes: 150 additions & 0 deletions src/components/ReceiptScanningLine.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';

import CONST from '@src/CONST';
import type {Dimensions} from '@src/types/utils/Layout';

import type {LayoutChangeEvent} from 'react-native';

import React, {useEffect, useId, useState} from 'react';
import {View} from 'react-native';
import Animated, {cancelAnimation, Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming} from 'react-native-reanimated';
import Svg, {Defs, LinearGradient, Rect, Stop} from 'react-native-svg';

import Image from './Image';
import RESIZE_MODES from './Image/resizeModes';
import LoadingIndicator from './LoadingIndicator';

const LOADING_CONTEXT = {context: 'ReceiptScanningLine'};

type ReceiptScanningLineProps = {
/** Receipt image being translated */
imageUri: string;

/** Whether the image needs the auth token to load */
isAuthTokenRequired?: boolean;

/** Called once the receipt image has loaded */
onLoad?: () => void;
};

/** Shows the receipt image with a scanning line moving over it while the receipt is translated */
function ReceiptScanningLine({imageUri, isAuthTokenRequired, onLoad}: ReceiptScanningLineProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const gradientID = useId();
const progress = useSharedValue(0);
const [containerSize, setContainerSize] = useState<Dimensions>({width: 0, height: 0});
const [imageSize, setImageSize] = useState<Dimensions>({width: 0, height: 0});

useEffect(() => {
progress.set(
withRepeat(
withTiming(1, {
duration: CONST.RECEIPT.TRANSLATION_SCAN_DURATION,
easing: Easing.bezier(0.76, 0.0, 0.24, 1.0),
}),
-1,
true,
),
);
return () => cancelAnimation(progress);
}, [progress]);

// The image is drawn with "contain", so the line has to match where the image actually lands inside the container
let displayWidth = 0;
let displayHeight = 0;
if (containerSize.width && containerSize.height && imageSize.width && imageSize.height) {
const imageAspectRatio = imageSize.width / imageSize.height;
if (imageAspectRatio > containerSize.width / containerSize.height) {
displayWidth = containerSize.width;
displayHeight = containerSize.width / imageAspectRatio;
} else {
displayHeight = containerSize.height;
displayWidth = containerSize.height * imageAspectRatio;
}
}

const animatedStyle = useAnimatedStyle(() => ({
top: progress.get() * (displayHeight - CONST.RECEIPT.TRANSLATION_SCAN_LINE_HEIGHT),
}));

const onContainerLayout = (event: LayoutChangeEvent) => {
const {width, height} = event.nativeEvent.layout;
setContainerSize({width, height});
};

const onImageLoad = (event: {nativeEvent: {width: number; height: number}}) => {
const {width, height} = event.nativeEvent;
if (!width || !height) {
return;
}
setImageSize({width, height});
onLoad?.();
};

return (
<View
style={[styles.flex1, styles.w100, styles.alignItemsCenter, styles.justifyContentCenter]}
onLayout={onContainerLayout}
>
{/* eslint-disable-next-line react-native-a11y/has-valid-accessibility-ignores-invert-colors -- Custom Image wrapper does not support this prop. */}
<Image
source={{uri: imageUri}}
resizeMode={RESIZE_MODES.contain}
style={[styles.h100, styles.w100]}
onLoad={onImageLoad}
isAuthTokenRequired={isAuthTokenRequired}
/>
{!imageSize.width && (
<LoadingIndicator
style={[styles.opacity1, styles.bgTransparent]}
extraLoadingContext={LOADING_CONTEXT}
/>
)}
{!!displayHeight && (
<View
pointerEvents="none"
style={[styles.pAbsolute, styles.overflowHidden, StyleUtils.getWidthAndHeightStyle(displayWidth, displayHeight)]}
>
<Animated.View style={[styles.receiptScanningLine, animatedStyle]}>
<Svg
width="100%"
height="100%"
>
<Defs>
<LinearGradient
id={gradientID}
x1="0"
y1="0"
x2="0"
y2="1"
>
<Stop
offset="0"
stopColor={theme.success}
stopOpacity={CONST.RECEIPT.TRANSLATION_SCAN_TINT_OPACITY}
/>
<Stop
offset="1"
stopColor={theme.success}
stopOpacity="0"
/>
</LinearGradient>
</Defs>
<Rect
width="100%"
height="100%"
fill={`url(#${gradientID})`}
/>
</Svg>
</Animated.View>
</View>
)}
</View>
);
}

export default ReceiptScanningLine;
37 changes: 35 additions & 2 deletions src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import useOriginalReportID from '@hooks/useOriginalReportID';
import usePermissions from '@hooks/usePermissions';
import {usePersonalDetail} from '@hooks/usePersonalDetails';
import usePrevious from '@hooks/usePrevious';
import useReceiptTranslation from '@hooks/useReceiptTranslation';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useReportsParentHierarchy from '@hooks/useReportsParentHierarchy';
import useReportTransactionsCollection from '@hooks/useReportTransactionsCollection';
Expand Down Expand Up @@ -211,7 +212,7 @@ function MoneyRequestReceiptView({
const receiptContainerRef = useRef<ComponentRef<typeof View> | null>(null);
const addButtonRef = useRef<ComponentRef<typeof View> | null>(null);
const [isPickerOpen, setIsPickerOpen] = useState(false);
const lazyIcons = useMemoizedLazyExpensifyIcons(['Expand', 'ReceiptPlus']);
const lazyIcons = useMemoizedLazyExpensifyIcons(['Expand', 'ReceiptPlus', 'Translate']);

const [policyTagList] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policy?.id}`);
// Browsers don't fire mouseenter when an element mounts under the cursor
Expand Down Expand Up @@ -273,6 +274,7 @@ function MoneyRequestReceiptView({
const resolvedTransactionThreadReport = resolveTransactionThreadReport(transaction, transactionThreadReport, report, parentReportAction);

const displayedTransaction = updatedTransaction ?? transaction;
const {canTranslate, isTranslateDisabled, startTranslation} = useReceiptTranslation(displayedTransaction);
const isDistanceRequest = isDistanceRequestTransactionUtils(displayedTransaction);

// The hover overlay shows the full distance e-receipt (map + amount + waypoints), so only surface it for
Expand Down Expand Up @@ -812,7 +814,10 @@ function MoneyRequestReceiptView({
/>
)}
{canExpandReceipt && (
<View style={[styles.receiptActionButtonsContainer, styles.pointerEventsBoxNone, !hovered && !isPickerOpen && deviceHasHoverSupport && styles.opacity0]}>
<View
style={[styles.receiptActionButtonsContainer, styles.pointerEventsBoxNone, !hovered && !isPickerOpen && deviceHasHoverSupport && styles.opacity0]}
dataSet={{[CONST.RECEIPT.HOVER_ZOOM_EXCLUDED_ELEMENT]: true}}
>
{canShowReceiptActions && (
<AttachmentPicker acceptedFileTypes={[...CONST.API_ATTACHMENT_VALIDATIONS.ALLOWED_RECEIPT_EXTENSIONS]}>
{({openPicker}) => (
Expand Down Expand Up @@ -853,6 +858,34 @@ function MoneyRequestReceiptView({
)}
</AttachmentPicker>
)}
{canTranslate &&
deviceHasHoverSupport && (
// TODO: The spec switches this tooltip to `View original` once translated. Add it when design confirms what the thumbnail shows then.
<Tooltip text={translate('receipt.translate')}>
<PressableWithoutFocus
onPress={() => {
startTranslation();
Navigation.navigate(
ROUTES.TRANSACTION_RECEIPT.getRoute(report?.reportID, displayedTransaction?.transactionID, readonly || !canEditReceipt),
);
}}
disabled={isTranslateDisabled}
style={styles.receiptActionButton}
disabledStyle={styles.buttonOpacityDisabled}
hoverStyle={styles.buttonDefaultHovered}
accessibilityLabel={translate('receipt.translate')}
role={CONST.ROLE.BUTTON}
sentryLabel={CONST.SENTRY_LABEL.RECEIPT.TRANSLATE_BUTTON}
>
<Icon
src={lazyIcons.Translate}
height={variables.iconSizeSmall}
width={variables.iconSizeSmall}
fill={theme.icon}
/>
</PressableWithoutFocus>
</Tooltip>
)}
<Tooltip text={translate('reportActionCompose.expand')}>
<PressableWithoutFocus
onPress={() =>
Expand Down
Loading
Loading