Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8454,9 +8454,6 @@ const CONST = {
ONBOARDING: {
INTERESTED_FEATURES_ITEM: 'Onboarding-InterestedFeaturesItem',
},
BASE_ANCHOR_FOR_ATTACHMENTS_ONLY: {
DOWNLOAD_BUTTON: 'BaseAnchorForAttachmentsOnly-DownloadButton',
},
REPORT_HEADER_SKELETON: {
GO_BACK: 'ReportHeaderSkeleton-GoBack',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import AttachmentView from '@components/Attachments/AttachmentView';
import {useSession} from '@components/OnyxListItemProvider';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext';
import useLocalize from '@hooks/useLocalize';
Expand All @@ -26,23 +25,21 @@
};

function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onPressIn, onPressOut, isDeleted}: BaseAnchorForAttachmentsOnlyProps) {
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source);
const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];

const [download] = useOnyx(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`, {canBeMissing: true});
const session = useSession();
const {translate} = useLocalize();

const {isOffline} = useNetwork();
const styles = useThemeStyles();

const isDownloading = download?.isDownloading ?? false;
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source, encryptedAuthToken);

return (
<ShowContextMenuContext.Consumer>
{({anchor, report, isReportArchived, action, checkIfContextMenuActive, isDisabled, shouldDisplayContextMenu}) => (
<PressableWithoutFeedback

Check failure on line 42 in src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

All Pressable components must include sentryLabel prop for Sentry tracking. Example: <PressableWithoutFeedback sentryLabel="MoreMenu-ExportFile" />

Check failure on line 42 in src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

All Pressable components must include sentryLabel prop for Sentry tracking. Example: <PressableWithoutFeedback sentryLabel="MoreMenu-ExportFile" />
style={[style, (isOffline || !sourceID) && styles.cursorDefault]}
onPress={() => {
if (isDownloading || isOffline || !sourceID) {
Expand All @@ -62,7 +59,6 @@
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
role={CONST.ROLE.BUTTON}
sentryLabel={CONST.SENTRY_LABEL.BASE_ANCHOR_FOR_ATTACHMENTS_ONLY.DOWNLOAD_BUTTON}
>
<AttachmentView
source={source}
Expand Down
5 changes: 1 addition & 4 deletions src/components/Attachments/AttachmentView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Button from '@components/Button';
import DistanceEReceipt from '@components/DistanceEReceipt';
import EReceipt from '@components/EReceipt';
import Icon from '@components/Icon';
import {useSession} from '@components/OnyxListItemProvider';
import PerDiemEReceipt from '@components/PerDiemEReceipt';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
Expand Down Expand Up @@ -135,8 +134,6 @@ function AttachmentView({
const icons = useMemoizedLazyExpensifyIcons(['ArrowCircleClockwise', 'Gallery']);
const [transactionFromOnyx] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`, {canBeMissing: true});
const transaction = transactionProp ?? transactionFromOnyx;
const session = useSession();
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const {translate} = useLocalize();
const {currentlyPlayingURL} = usePlaybackStateContext();
const {updateCurrentURLAndReportID, playVideo} = usePlaybackActionsContext();
Expand Down Expand Up @@ -223,7 +220,7 @@ function AttachmentView({
const isSourcePDF = typeof source === 'string' && Str.isPDF(source);
const isFilePDF = file && Str.isPDF(file.name ?? translate('attachmentView.unknownFilename'));
if (!hasPDFFailedToLoad && !isUploading && (isSourcePDF || isFilePDF)) {
const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source as string, encryptedAuthToken) : (source as string);
const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source as string) : (source as string);

const onPDFLoadComplete = (path: string) => {
const id = (transaction && transaction.transactionID) ?? reportActionID;
Expand Down
6 changes: 1 addition & 5 deletions src/components/Composer/implementation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React, {useCallback, useEffect, useImperativeHandle, useMemo, useRef, use
import type {TextInputKeyPressEvent, TextInputSelectionChangeEvent} from 'react-native';
import {DeviceEventEmitter, StyleSheet} from 'react-native';
import type {ComposerProps} from '@components/Composer/types';
import {useSession} from '@components/OnyxListItemProvider';
import type {AnimatedMarkdownTextInputRef} from '@components/RNMarkdownTextInput';
import RNMarkdownTextInput from '@components/RNMarkdownTextInput';
import useHtmlPaste from '@hooks/useHtmlPaste';
Expand Down Expand Up @@ -56,9 +55,6 @@ function Composer({
const textContainsOnlyEmojis = useMemo(() => containsOnlyEmojis(Parser.htmlToText(Parser.replace(value ?? ''))), [value]);
const theme = useTheme();
const styles = useThemeStyles();
const session = useSession();
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const addAuthTokenToImageURL = (url: string) => addEncryptedAuthTokenToURL(url, encryptedAuthToken);
const markdownStyle = useMarkdownStyle(textContainsOnlyEmojis, !isGroupPolicyReport ? excludeReportMentionStyle : excludeNoStyles);
const StyleUtils = useStyleUtils();
const textInput = useRef<AnimatedMarkdownTextInputRef | null>(null);
Expand Down Expand Up @@ -365,7 +361,7 @@ function Composer({
}}
disabled={isDisabled}
onKeyPress={handleKeyPress}
addAuthTokenToImageURLCallback={addAuthTokenToImageURL}
addAuthTokenToImageURLCallback={addEncryptedAuthTokenToURL}
imagePreviewAuthRequiredURLs={imagePreviewAuthRequiredURLs}
/>
);
Expand Down
7 changes: 3 additions & 4 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ function MoneyReportHeader({
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true});
const [reportPDFFilename] = useOnyx(`${ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDF_FILENAME}${moneyRequestReport?.reportID}`, {canBeMissing: true}) ?? null;
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const activePolicy = usePolicy(activePolicyID);
Expand Down Expand Up @@ -1625,9 +1624,9 @@ function MoneyReportHeader({
if (!hasFinishedPDFDownload || !canTriggerAutomaticPDFDownload.current) {
return;
}
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, currentUserLogin ?? '', encryptedAuthToken);
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, currentUserLogin ?? '');
canTriggerAutomaticPDFDownload.current = false;
}, [hasFinishedPDFDownload, reportPDFFilename, moneyRequestReport?.reportName, translate, currentUserLogin, encryptedAuthToken]);
}, [hasFinishedPDFDownload, reportPDFFilename, moneyRequestReport?.reportName, translate, currentUserLogin]);

const shouldShowBackButton = shouldDisplayBackButton || shouldUseNarrowLayout;

Expand Down Expand Up @@ -1966,7 +1965,7 @@ function MoneyReportHeader({
if (!hasFinishedPDFDownload) {
setIsPDFModalVisible(false);
} else {
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, currentUserLogin ?? '', encryptedAuthToken);
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, currentUserLogin ?? '');
}
}}
text={hasFinishedPDFDownload ? translate('common.download') : translate('common.cancel')}
Expand Down
5 changes: 3 additions & 2 deletions src/components/PDFThumbnail/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import {View} from 'react-native';
import Pdf from 'react-native-pdf';
import LoadingIndicator from '@components/LoadingIndicator';
import useThemeStyles from '@hooks/useThemeStyles';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import PDFThumbnailError from './PDFThumbnailError';
import type PDFThumbnailProps from './types';

function PDFThumbnail({previewSourceURL, style, enabled = true, fitPolicy = 0, onPassword, onLoadError, onLoadSuccess}: PDFThumbnailProps) {
function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, fitPolicy = 0, onPassword, onLoadError, onLoadSuccess}: PDFThumbnailProps) {
const styles = useThemeStyles();
const sizeStyles = [styles.w100, styles.h100];
const [failedToLoad, setFailedToLoad] = useState(false);
Expand All @@ -19,7 +20,7 @@ function PDFThumbnail({previewSourceURL, style, enabled = true, fitPolicy = 0, o
fitPolicy={fitPolicy}
trustAllCerts={false}
renderActivityIndicator={() => <LoadingIndicator />}
source={{uri: previewSourceURL}}
source={{uri: isAuthTokenRequired ? addEncryptedAuthTokenToURL(previewSourceURL) : previewSourceURL}}
singlePage
style={sizeStyles}
onError={(error) => {
Expand Down
7 changes: 4 additions & 3 deletions src/components/PDFThumbnail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import {View} from 'react-native';
import {Document, pdfjs, Thumbnail} from 'react-pdf';
import LoadingIndicator from '@components/LoadingIndicator';
import useThemeStyles from '@hooks/useThemeStyles';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import PDFThumbnailError from './PDFThumbnailError';
import type PDFThumbnailProps from './types';

if (!pdfjs.GlobalWorkerOptions.workerSrc) {
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerSource], {type: 'text/javascript'}));
}

function PDFThumbnail({previewSourceURL, style, enabled = true, onPassword, onLoadError, onLoadSuccess}: PDFThumbnailProps) {
function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, onPassword, onLoadError, onLoadSuccess}: PDFThumbnailProps) {
const styles = useThemeStyles();
const [failedToLoad, setFailedToLoad] = useState(false);

const thumbnail = useMemo(
() => (
<Document
loading={<LoadingIndicator />}
file={previewSourceURL}
file={isAuthTokenRequired ? addEncryptedAuthTokenToURL(previewSourceURL) : previewSourceURL}
options={{
cMapUrl: 'cmaps/',
cMapPacked: true,
Expand Down Expand Up @@ -50,7 +51,7 @@ function PDFThumbnail({previewSourceURL, style, enabled = true, onPassword, onLo
</View>
</Document>
),
[previewSourceURL, onPassword, onLoadError, onLoadSuccess],
[isAuthTokenRequired, previewSourceURL, onPassword, onLoadError, onLoadSuccess],
);

return (
Expand Down
3 changes: 3 additions & 0 deletions src/components/PDFThumbnail/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ type PDFThumbnailProps = {
/** Any additional styles to apply */
style?: StyleProp<ViewStyle>;

/** Whether the PDF thumbnail requires an authToken */
isAuthTokenRequired?: boolean;

/** Whether the PDF thumbnail can be loaded */
enabled?: boolean;

Expand Down
5 changes: 1 addition & 4 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {scheduleOnRN} from 'react-native-worklets';
import AttachmentOfflineIndicator from '@components/AttachmentOfflineIndicator';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import Hoverable from '@components/Hoverable';
import {useSession} from '@components/OnyxListItemProvider';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import {useFullScreenContext} from '@components/VideoPlayerContexts/FullScreenContext';
import {usePlaybackActionsContext, usePlaybackStateContext} from '@components/VideoPlayerContexts/PlaybackContext';
Expand Down Expand Up @@ -59,13 +58,11 @@ function BaseVideoPlayer({
const {isFullScreenRef} = useFullScreenContext();

const isOffline = useNetwork().isOffline;
const session = useSession();
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const [duration, setDuration] = useState(videoDuration);
const [isEnded, setIsEnded] = useState(false);
const [isFirstLoad, setIsFirstLoad] = useState(true);
// we add "#t=0.001" at the end of the URL to skip first millisecond of the video and always be able to show proper video preview when video is paused at the beginning
const [sourceURL] = useState(() => VideoUtils.addSkipTimeTagToURL(url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url, encryptedAuthToken), 0.001));
const [sourceURL] = useState(() => VideoUtils.addSkipTimeTagToURL(url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url), 0.001));
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
const [popoverAnchorPosition, setPopoverAnchorPosition] = useState({horizontal: 0, vertical: 0});
const [controlStatusState, setControlStatusState] = useState(controlsStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {VideoPlayer} from 'expo-video';
import React, {useCallback, useContext, useMemo, useRef, useState} from 'react';
// eslint-disable-next-line no-restricted-imports
import * as Expensicons from '@components/Icon/Expensicons';
import {useSession} from '@components/OnyxListItemProvider';
import type {PopoverMenuItem} from '@components/PopoverMenu';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Expand All @@ -23,8 +22,6 @@ function VideoPopoverMenuContextProvider({children}: ChildrenProps) {
const {isOffline} = useNetwork();
const isLocalFile = source && CONST.ATTACHMENT_LOCAL_URL_PREFIX.some((prefix) => source.startsWith(prefix));
const videoPopoverMenuPlayerRef = useRef<VideoPlayer>(null);
const session = useSession();
const encryptedAuthToken = session?.encryptedAuthToken ?? '';

const updatePlaybackSpeed = useCallback(
(speed: PlaybackSpeed) => {
Expand All @@ -45,8 +42,8 @@ function VideoPopoverMenuContextProvider({children}: ChildrenProps) {
if (typeof source === 'number' || !source) {
return;
}
fileDownload(translate, addEncryptedAuthTokenToURL(source, encryptedAuthToken));
}, [source, translate, encryptedAuthToken]);
fileDownload(translate, addEncryptedAuthTokenToURL(source));
}, [source, translate]);

const menuItems = useMemo(() => {
const items: PopoverMenuItem[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
/** @deprecated This value is deprecated and will be removed soon after migration. Use the email from useCurrentUserPersonalDetails hook instead. */
let deprecatedCurrentUserLogin: string | undefined;

Onyx.connect({

Check warning on line 315 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 315 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -326,7 +326,7 @@
},
});

Onyx.connect({

Check warning on line 329 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 329 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => (conciergeReportIDOnyxConnect = value),
});
Expand All @@ -334,7 +334,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 337 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 337 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
callback: (actions, key) => {
if (!key || !actions) {
Expand All @@ -346,7 +346,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 349 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -355,7 +355,7 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({

Check warning on line 358 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand All @@ -370,7 +370,7 @@
});

let onboarding: OnyxEntry<Onboarding>;
Onyx.connect({

Check warning on line 373 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ONBOARDING,
callback: (val) => {
if (Array.isArray(val)) {
Expand All @@ -381,7 +381,7 @@
});

let deprecatedIntroSelected: OnyxEntry<IntroSelected> = {};
Onyx.connect({

Check warning on line 384 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_INTRO_SELECTED,
callback: (val) => (deprecatedIntroSelected = val),
});
Expand Down Expand Up @@ -5031,14 +5031,14 @@
API.write(WRITE_COMMANDS.EXPORT_REPORT_TO_PDF, params, {optimisticData, failureData});
}

function downloadReportPDF(fileName: string, reportName: string, translate: LocalizedTranslate, currentUserLogin: string, encryptedAuthToken: string) {
function downloadReportPDF(fileName: string, reportName: string, translate: LocalizedTranslate, currentUserLogin: string) {
const baseURL = addTrailingForwardSlash(getOldDotURLFromEnvironment(environment));
const downloadFileName = `${reportName}.pdf`;
setDownload(fileName, true);
const pdfURL = `${baseURL}secure?secureType=pdfreport&filename=${encodeURIComponent(fileName)}&downloadName=${encodeURIComponent(downloadFileName)}&email=${encodeURIComponent(
currentUserLogin,
)}`;
fileDownload(translate, addEncryptedAuthTokenToURL(pdfURL, encryptedAuthToken, true), downloadFileName, '', Browser.isMobileSafari()).then(() => setDownload(fileName, false));
fileDownload(translate, addEncryptedAuthTokenToURL(pdfURL, true), downloadFileName, '', Browser.isMobileSafari()).then(() => setDownload(fileName, false));
}

function setDeleteTransactionNavigateBackUrl(url: string) {
Expand Down
14 changes: 13 additions & 1 deletion src/libs/addEncryptedAuthTokenToURL.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';

let encryptedAuthToken = '';
// We use `connectWithoutView` here since this connection only updates a module-level variable
// and doesn't need to trigger component re-renders. UI components get the current token
// value when they call the exported function.
Onyx.connectWithoutView({
key: ONYXKEYS.SESSION,
callback: (session) => (encryptedAuthToken = session?.encryptedAuthToken ?? ''),
});

/**
* Add encryptedAuthToken to this attachment URL
*/
export default function addEncryptedAuthTokenToURL(url: string, encryptedAuthToken: string, hasOtherParameters = false) {
export default function (url: string, hasOtherParameters = false) {
const symbol = hasOtherParameters ? '&' : '?';
return `${url}${symbol}encryptedAuthToken=${encodeURIComponent(encryptedAuthToken)}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as ActionSheetAwareScrollView from '@components/ActionSheetAwareScrollV
import ContextMenuItem from '@components/ContextMenuItem';
import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider';
import FocusTrapForModal from '@components/FocusTrap/FocusTrapForModal';
import {useSession} from '@components/OnyxListItemProvider';
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useEnvironment from '@hooks/useEnvironment';
Expand Down Expand Up @@ -241,8 +240,6 @@ function BaseReportActionContextMenu({
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});

const isTryNewDotNVPDismissed = !!tryNewDot?.classicRedirect?.dismissed;
const session = useSession();
const encryptedAuthToken = session?.encryptedAuthToken ?? '';

const isMoneyRequest = useMemo(() => ReportUtilsIsMoneyRequest(childReport), [childReport]);
const isTrackExpenseReport = ReportUtilsIsTrackExpenseReport(childReport);
Expand Down Expand Up @@ -404,7 +401,6 @@ function BaseReportActionContextMenu({
showDelegateNoAccessModal,
currentUserAccountID: currentUserPersonalDetails?.accountID,
currentUserPersonalDetails,
encryptedAuthToken,
};

if ('renderContent' in contextAction) {
Expand Down
5 changes: 2 additions & 3 deletions src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ type ContextMenuActionPayload = {
isDelegateAccessRestricted?: boolean;
showDelegateNoAccessModal?: () => void;
currentUserPersonalDetails: ReturnType<typeof useCurrentUserPersonalDetails>;
encryptedAuthToken: string;
};

type OnPress = (closePopover: boolean, payload: ContextMenuActionPayload, selection?: string, reportID?: string, draftMessage?: string) => void;
Expand Down Expand Up @@ -1184,10 +1183,10 @@ const ContextMenuActions: ContextMenuAction[] = [
const isUploading = html.includes(CONST.ATTACHMENT_OPTIMISTIC_SOURCE_ATTRIBUTE);
return isAttachment && !isUploading && !!reportAction?.reportActionID && !isMessageDeleted(reportAction) && !isOffline;
},
onPress: (closePopover, {reportAction, translate, encryptedAuthToken}) => {
onPress: (closePopover, {reportAction, translate}) => {
const html = getActionHtml(reportAction);
const {originalFileName, sourceURL} = getAttachmentDetails(html);
const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? '', encryptedAuthToken);
const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? '');
const sourceID = (sourceURL?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];
setDownload(sourceID, true);
const anchorRegex = CONST.REGEX_LINK_IN_ANCHOR;
Expand Down
Loading
Loading