Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b0c76b5
Initial fix of the propert state restoration after reload on odometer…
jakubkalinski0 Feb 27, 2026
10f34d0
Merge branch 'main' into jakubkalinski0/Odometer_redirected_back_to_i…
jakubkalinski0 Feb 27, 2026
7fb25a9
Merge branch 'main' into jakubkalinski0/Odometer_redirected_back_to_i…
jakubkalinski0 Mar 4, 2026
4abc137
fix: removed duplicated replace button
jakubkalinski0 Mar 4, 2026
20a3acc
fix: added source route recognition for odometer image preview
jakubkalinski0 Mar 4, 2026
d999d05
fix: changed odometer image route to properly parse isEditingConfirma…
jakubkalinski0 Mar 4, 2026
0f6fc47
Merge branch 'main' into jakubkalinski0/Odometer_redirected_back_to_i…
jakubkalinski0 Mar 5, 2026
c816448
fix: remove premature redundant blob URL cleanup of odometer images
jakubkalinski0 Mar 5, 2026
2ccbaad
fix: adjust odomterImage types in Transaction to match the truth
jakubkalinski0 Mar 5, 2026
7b7e827
Merge branch 'main' into jakubkalinski0/Odometer_redirected_back_to_i…
jakubkalinski0 Mar 5, 2026
b856ff5
improvement: replace sketchy route stack check with separate routes t…
jakubkalinski0 Mar 5, 2026
a4e5414
Merge branch 'main' into jakubkalinski0/Odometer_redirected_back_to_i…
jakubkalinski0 Mar 6, 2026
165a5cd
fix: changed log messages of new odometer routes to use proper consts
jakubkalinski0 Mar 6, 2026
6f23df1
refactor: memoize navigation handlers in IOURequestStepDistanceOdometer
jakubkalinski0 Mar 6, 2026
f742b4c
prettier run
jakubkalinski0 Mar 6, 2026
09eb6c7
fix: add 'as string' casts to odometer route template literals to pre…
jakubkalinski0 Mar 6, 2026
2d04cf5
improvement: simplified 2 odometer preview routes into a single route…
jakubkalinski0 Mar 9, 2026
a68e9d3
fix: add backTo to odometer preview route to prevent losing it on odo…
jakubkalinski0 Mar 9, 2026
624c6f1
prettier run
jakubkalinski0 Mar 9, 2026
7e002cf
fix: move imageType to queryParams to avoid confusion in getRoute
jakubkalinski0 Mar 9, 2026
b0c18cc
fix: spellcheck in odometer preview route log
jakubkalinski0 Mar 9, 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
24 changes: 18 additions & 6 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,15 +1126,27 @@ const ROUTES = {
getUrlWithBackToParam(`${action as string}/${iouType as string}/report/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo),
},
MONEY_REQUEST_RECEIPT_PREVIEW: {
route: ':action/:iouType/receipt/:transactionID/:reportID/:imageType?',
getRoute: (reportID: string, transactionID: string, action: IOUAction, iouType: IOUType, imageType?: OdometerImageType) => {
route: ':action/:iouType/receipt/:transactionID/:reportID',
getRoute: (reportID: string, transactionID: string, action: IOUAction, iouType: IOUType) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the MONEY_REQUEST_RECEIPT_PREVIEW route');
}
if (!transactionID) {
Log.warn('Invalid transactionID is used to build the MONEY_REQUEST_RECEIPT_PREVIEW route');
}
return `${action}/${iouType}/receipt/${transactionID}/${reportID}?readonly=false${imageType ? `&imageType=${imageType}` : ''}` as const;
return `${action as string}/${iouType as string}/receipt/${transactionID}/${reportID}?readonly=false` as const;
},
},
MONEY_REQUEST_ODOMETER_PREVIEW: {
route: ':action/:iouType/odometer-image-preview/:transactionID/:reportID/:backToReport?',
getRoute: (reportID: string, transactionID: string, action: IOUAction, iouType: IOUType, imageType: OdometerImageType, isEditingConfirmation: boolean, backToReport?: string) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the MONEY_REQUEST_ODOMETER_PREVIEW route');
}
if (!transactionID) {
Log.warn('Invalid transactionID is used to build the MONEY_REQUEST_ODOMETER_PREVIEW route');
}
return `${action as string}/${iouType as string}/odometer-image-preview/${transactionID}/${reportID}${backToReport ? `/${backToReport}` : ''}?readonly=false&imageType=${imageType}${isEditingConfirmation ? '&isEditingConfirmation=true' : ''}` as const;
},
},
MONEY_REQUEST_EDIT_REPORT: {
Expand Down Expand Up @@ -1475,9 +1487,9 @@ const ROUTES = {
`${action as string}/${iouType as string}/start/${transactionID}/${reportID}/distance-new${backToReport ? `/${backToReport}` : ''}/distance-odometer` as const,
},
ODOMETER_IMAGE: {
route: ':action/:iouType/odometer-image/:transactionID/:reportID/:imageType',
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, imageType: OdometerImageType) =>
`${action as string}/${iouType as string}/odometer-image/${transactionID}/${reportID}/${imageType}` as const,
route: ':action/:iouType/odometer-image/:transactionID/:reportID/:imageType/:backToReport?',
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, imageType: OdometerImageType, isEditingConfirmation?: boolean, backToReport?: string) =>
`${action as string}/${iouType as string}/odometer-image/${transactionID}/${reportID}/${imageType}${backToReport ? `/${backToReport}` : ''}${isEditingConfirmation ? '?isEditingConfirmation=true' : ''}` as const,
},
IOU_SEND_ADD_BANK_ACCOUNT: 'pay/new/add-bank-account',
IOU_SEND_ADD_DEBIT_CARD: 'pay/new/add-debit-card',
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ const SCREENS = {
STEP_DISTANCE_ODOMETER: 'Money_Request_Step_Distance_Odometer',
ODOMETER_IMAGE: 'Money_Request_Odometer_Image',
RECEIPT_PREVIEW: 'Money_Request_Receipt_preview',
ODOMETER_PREVIEW: 'Money_Request_Odometer_Preview',
STEP_TIME_RATE: 'Money_Request_Step_Time_Rate',
STEP_HOURS: 'Money_Request_Step_Hours',
STEP_HOURS_EDIT: 'Money_Request_Step_Hours_Edit',
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ function AuthScreens() {
getComponent={loadAttachmentModalScreen}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name={SCREENS.MONEY_REQUEST.ODOMETER_PREVIEW}
options={attachmentModalScreenOptions}
getComponent={loadAttachmentModalScreen}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name={SCREENS.NOT_FOUND}
options={rootNavigatorScreenOptions.fullScreen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const MODAL_ROUTES_TO_DISMISS = new Set<string>([
SCREENS.REPORT_ADD_ATTACHMENT,
SCREENS.TRANSACTION_RECEIPT,
SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW,
SCREENS.MONEY_REQUEST.ODOMETER_PREVIEW,
SCREENS.PROFILE_AVATAR,
SCREENS.WORKSPACE_AVATAR,
SCREENS.REPORT_AVATAR,
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.REPORT_AVATAR]: ROUTES.REPORT_AVATAR.route,
[SCREENS.TRANSACTION_RECEIPT]: ROUTES.TRANSACTION_RECEIPT.route,
[SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW]: ROUTES.MONEY_REQUEST_RECEIPT_PREVIEW.route,
[SCREENS.MONEY_REQUEST.ODOMETER_PREVIEW]: ROUTES.MONEY_REQUEST_ODOMETER_PREVIEW.route,
[SCREENS.WORKSPACE_JOIN_USER]: ROUTES.WORKSPACE_JOIN_USER.route,
[SCREENS.WORKSPACES_LIST]: {
path: ROUTES.WORKSPACES_LIST.route,
Expand Down
14 changes: 14 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,9 @@ type MoneyRequestNavigatorParamList = {
iouType: IOUType;
transactionID: string;
reportID: string;
backToReport?: string;
imageType: OdometerImageType;
isEditingConfirmation?: string;
};
[SCREENS.MONEY_REQUEST.CREATE]: {
iouType: IOUType;
Expand Down Expand Up @@ -2924,6 +2926,8 @@ type AttachmentModalScreensParamList = {
iouType?: IOUType;
mergeTransactionID?: string;
imageType?: OdometerImageType;
isEditingConfirmation?: boolean;
backToReport?: string;
};
[SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW]: AttachmentModalContainerModalProps & {
reportID: string;
Expand All @@ -2932,6 +2936,16 @@ type AttachmentModalScreensParamList = {
iouType: IOUType;
readonly: string;
};
[SCREENS.MONEY_REQUEST.ODOMETER_PREVIEW]: AttachmentModalContainerModalProps & {
reportID: string;
transactionID: string;
action: IOUAction;
iouType: IOUType;
readonly: string;
imageType: OdometerImageType;
isEditingConfirmation: boolean;
backToReport?: string;
};
[SCREENS.SHARE.SHARE_DETAILS_ATTACHMENT]: AttachmentModalContainerModalProps & {
source?: AvatarSource;
fallbackSource?: AvatarSource;
Expand Down
64 changes: 25 additions & 39 deletions src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function IOURequestStepDistanceOdometer({
const theme = useTheme();
const StyleUtils = useStyleUtils();
const {isExtraSmallScreenHeight} = useResponsiveLayout();
const icons = useMemoizedLazyExpensifyIcons(['GalleryPlus'] as const);

const startReadingInputRef = useRef<BaseTextInputRef | null>(null);
const endReadingInputRef = useRef<BaseTextInputRef | null>(null);
Expand Down Expand Up @@ -258,24 +259,6 @@ function IOURequestStepDistanceOdometer({
const startImageSource = useMemo(() => getImageSource(odometerStartImage), [getImageSource, odometerStartImage]);
const endImageSource = useMemo(() => getImageSource(odometerEndImage), [getImageSource, odometerEndImage]);

useEffect(() => {
return () => {
if (!startImageSource?.startsWith('blob:')) {
return;
}
URL.revokeObjectURL(startImageSource);
};
}, [startImageSource]);

useEffect(() => {
return () => {
if (!endImageSource?.startsWith('blob:')) {
return;
}
URL.revokeObjectURL(endImageSource);
};
}, [endImageSource]);

const buttonText = (() => {
if (shouldSkipConfirmation) {
return translate('iou.createExpense');
Expand Down Expand Up @@ -338,32 +321,47 @@ function IOURequestStepDistanceOdometer({

const handleCaptureImage = useCallback(
(imageType: OdometerImageType) => {
Navigation.navigate(ROUTES.ODOMETER_IMAGE.getRoute(action, iouType, transactionID, reportID, imageType));
Navigation.navigate(ROUTES.ODOMETER_IMAGE.getRoute(action, iouType, transactionID, reportID, imageType, isEditingConfirmation, backToReport));
},
[action, iouType, transactionID, reportID],
[action, iouType, transactionID, reportID, isEditingConfirmation, backToReport],
);

const handleViewOdometerImage = useCallback(
(imageType: OdometerImageType) => {
if (!reportID || !transactionID) {
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_RECEIPT_PREVIEW.getRoute(reportID, transactionID, action, iouType, imageType));
Navigation.navigate(ROUTES.MONEY_REQUEST_ODOMETER_PREVIEW.getRoute(reportID, transactionID, action, iouType, imageType, isEditingConfirmation, backToReport));
},
[reportID, transactionID, action, iouType],
[reportID, transactionID, isEditingConfirmation, action, iouType, backToReport],
);

const navigateBack = () => {
const navigateBack = useCallback(() => {
if (isEditingConfirmation) {
Navigation.goBack(confirmationRoute);
return;
}
Navigation.goBack();
Comment thread
jakubkalinski0 marked this conversation as resolved.
Resolved
};
}, [isEditingConfirmation, confirmationRoute]);

const handlePressStartImage = useCallback(() => {
if (odometerStartImage) {
handleViewOdometerImage(CONST.IOU.ODOMETER_IMAGE_TYPE.START);
} else {
handleCaptureImage(CONST.IOU.ODOMETER_IMAGE_TYPE.START);
}
}, [odometerStartImage, handleViewOdometerImage, handleCaptureImage]);

const handlePressEndImage = useCallback(() => {
if (odometerEndImage) {
handleViewOdometerImage(CONST.IOU.ODOMETER_IMAGE_TYPE.END);
} else {
handleCaptureImage(CONST.IOU.ODOMETER_IMAGE_TYPE.END);
}
}, [odometerEndImage, handleViewOdometerImage, handleCaptureImage]);

const [recentWaypoints] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const icons = useMemoizedLazyExpensifyIcons(['GalleryPlus'] as const);
// Navigate to next page following Manual tab pattern
const navigateToNextPage = () => {
const start = parseFloat(DistanceRequestUtils.normalizeOdometerText(startReading, fromLocaleDigit));
Expand Down Expand Up @@ -542,13 +540,7 @@ function IOURequestStepDistanceOdometer({
accessibilityRole="button"
accessibilityLabel={translate('distance.odometer.startTitle')}
sentryLabel={CONST.SENTRY_LABEL.ODOMETER_EXPENSE.CAPTURE_IMAGE_START}
onPress={() => {
if (odometerStartImage) {
handleViewOdometerImage(CONST.IOU.ODOMETER_IMAGE_TYPE.START);
} else {
handleCaptureImage(CONST.IOU.ODOMETER_IMAGE_TYPE.START);
}
}}
onPress={handlePressStartImage}
style={[
StyleUtils.getWidthAndHeightStyle(variables.inputHeight, variables.inputHeight),
StyleUtils.getBorderRadiusStyle(variables.componentBorderRadiusMedium),
Expand Down Expand Up @@ -590,13 +582,7 @@ function IOURequestStepDistanceOdometer({
accessibilityRole="button"
accessibilityLabel={translate('distance.odometer.endTitle')}
sentryLabel={CONST.SENTRY_LABEL.ODOMETER_EXPENSE.CAPTURE_IMAGE_END}
onPress={() => {
if (odometerEndImage) {
handleViewOdometerImage(CONST.IOU.ODOMETER_IMAGE_TYPE.END);
} else {
handleCaptureImage(CONST.IOU.ODOMETER_IMAGE_TYPE.END);
}
}}
onPress={handlePressEndImage}
style={[
StyleUtils.getWidthAndHeightStyle(variables.inputHeight, variables.inputHeight),
StyleUtils.getBorderRadiusStyle(variables.componentBorderRadiusMedium),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import variables from '@styles/variables';
import {setMoneyRequestOdometerImage} from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type {FileObject} from '@src/types/utils/Attachment';
import {getEmptyObject} from '@src/types/utils/EmptyObject';
Expand All @@ -63,7 +64,7 @@ function focusCamera(cameraRef: React.RefObject<Camera | null>, point: Point) {

function IOURequestStepOdometerImage({
route: {
params: {action, iouType, transactionID, imageType},
params: {action, iouType, transactionID, reportID, backToReport, imageType, isEditingConfirmation},
},
}: IOURequestStepOdometerImageProps) {
const {translate} = useLocalize();
Expand Down Expand Up @@ -95,8 +96,13 @@ function IOURequestStepOdometerImage({
const snapPhotoText = imageType === CONST.IOU.ODOMETER_IMAGE_TYPE.START ? translate('distance.odometer.snapPhotoStart') : translate('distance.odometer.snapPhotoEnd');
const icon = imageType === CONST.IOU.ODOMETER_IMAGE_TYPE.START ? lazyIcons.OdometerStart : lazyIcons.OdometerEnd;

const goBackRoute =
isEditingConfirmation === 'true'
? ROUTES.MONEY_REQUEST_STEP_DISTANCE_ODOMETER.getRoute(action, iouType, transactionID, reportID)
: ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER.getRoute(action, iouType, transactionID, reportID, backToReport);
Comment thread
jakubkalinski0 marked this conversation as resolved.
Resolved

const navigateBack = () => {
Navigation.goBack();
Navigation.goBack(goBackRoute);
};

const askForPermissions = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type IOURequestStepOdometerImageProps = WithFullTransactionOrNotFoundProps<typeo

function IOURequestStepOdometerImage({
route: {
params: {action, iouType, transactionID, reportID, imageType},
params: {action, iouType, transactionID, reportID, backToReport, imageType, isEditingConfirmation},
},
}: IOURequestStepOdometerImageProps) {
const {translate} = useLocalize();
Expand Down Expand Up @@ -77,10 +77,13 @@ function IOURequestStepOdometerImage({
const icon = imageType === CONST.IOU.ODOMETER_IMAGE_TYPE.START ? lazyIcons.OdometerStart : lazyIcons.OdometerEnd;
const messageHTML = `<centered-text><muted-text-label>${message}</muted-text-label></centered-text>`;

const odometerRoute = ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER.getRoute(action, iouType, transactionID, reportID);
const goBackRoute =
isEditingConfirmation === 'true'
? ROUTES.MONEY_REQUEST_STEP_DISTANCE_ODOMETER.getRoute(action, iouType, transactionID, reportID)
: ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER.getRoute(action, iouType, transactionID, reportID, backToReport);

const navigateBack = () => {
Navigation.goBack(odometerRoute);
Navigation.goBack(goBackRoute);
};

const handleImageSelected = (file: FileObject) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/media/AttachmentModalScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function AttachmentModalScreen<Screen extends AttachmentModalScreenType>({route,
);
}

if (route.name === SCREENS.TRANSACTION_RECEIPT || route.name === SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW) {
if (route.name === SCREENS.TRANSACTION_RECEIPT || route.name === SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW || route.name === SCREENS.MONEY_REQUEST.ODOMETER_PREVIEW) {
return (
<TransactionReceiptModalContent
route={routeWithContext as RouteType<typeof SCREENS.TRANSACTION_RECEIPT>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import type {FileObject} from '@src/types/utils/Attachment';
import useDownloadAttachment from './hooks/useDownloadAttachment';

function TransactionReceiptModalContent({navigation, route}: AttachmentModalScreenProps<typeof SCREENS.TRANSACTION_RECEIPT>) {
const {reportID, transactionID, action, iouType: iouTypeParam, readonly: readonlyParam, mergeTransactionID, imageType} = route.params;
const {reportID, transactionID, action, iouType: iouTypeParam, readonly: readonlyParam, mergeTransactionID, imageType, isEditingConfirmation, backToReport} = route.params;

const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -510,7 +510,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
onPress={() => {
const getDestinationRoute = () => {
return isOdometerImage
? ROUTES.ODOMETER_IMAGE.getRoute(action ?? CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, imageType)
? ROUTES.ODOMETER_IMAGE.getRoute(action ?? CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, imageType, isEditingConfirmation, backToReport)
: ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
action ?? CONST.IOU.ACTION.EDIT,
iouType,
Expand Down Expand Up @@ -566,6 +566,8 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
transactionID,
reportID,
imageType,
isEditingConfirmation,
backToReport,
draftTransactionID,
transaction?.transactionID,
report?.reportID,
Expand Down
1 change: 1 addition & 0 deletions src/pages/media/AttachmentModalScreen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type AttachmentModalScreenType =
| typeof SCREENS.WORKSPACE_AVATAR
| typeof SCREENS.TRANSACTION_RECEIPT
| typeof SCREENS.MONEY_REQUEST.RECEIPT_PREVIEW
| typeof SCREENS.MONEY_REQUEST.ODOMETER_PREVIEW
| typeof SCREENS.SHARE.SHARE_DETAILS_ATTACHMENT;

type AttachmentModalScreenBaseParams = AttachmentModalBaseContentProps & AttachmentModalContainerModalProps;
Expand Down
9 changes: 5 additions & 4 deletions src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {KeysOfUnion, ValueOf} from 'type-fest';
import type {CreateTrackExpenseParams, IOURequestType, ReplaceReceipt, RequestMoneyInformation, StartSplitBilActionParams} from '@libs/actions/IOU';
import type CONST from '@src/CONST';
import type ONYXKEYS from '@src/ONYXKEYS';
import type {FileObject} from '@src/types/utils/Attachment';
import type CollectionDataSet from '@src/types/utils/CollectionDataSet';
import type {Accountant, Attendee, Participant, Split, SplitExpense} from './IOU';
import type * as OnyxCommon from './OnyxCommon';
Expand Down Expand Up @@ -127,11 +128,11 @@ type Comment = {
odometerEnd?: number;

/** Both image fields are needed only locally because server receives only one merged image as receipt */
/** Odometer start image (File object on web, URI string on native) */
odometerStartImage?: File | string;
/** Odometer start image (File object with uri on web, URI string on native) */
odometerStartImage?: FileObject | string;

/** Odometer end image (File object on web, URI string on native) */
odometerEndImage?: File | string;
/** Odometer end image (File object with uri on web, URI string on native) */
odometerEndImage?: FileObject | string;
};

/** Model of transaction custom unit */
Expand Down
Loading