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: 3 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8789,6 +8789,9 @@ const CONST = {
TRANSACTION_PREVIEW: {
CARD: 'TransactionPreview-Card',
},
TRIP_ROOM_PREVIEW: {
CARD: 'TripRoomPreview-Card',
},

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.

@tgolen I see this was added for a sentry label, do we need to QA anything there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope!

TRANSACTION_ITEM_ROW: {
ARROW_RIGHT: 'TransactionItemRow-ArrowRight',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source, encryptedAuthToken);

const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
const {checkIfContextMenuActive} = useShowContextMenuActions();

return (
Expand All @@ -58,7 +58,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived));
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived), originalReportID);
}}
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function ImageRenderer({tnode}: CustomRendererProps<TBlock>) {
/>
);

const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();

return imagePreviewModalDisabled ? (
Expand Down Expand Up @@ -124,7 +124,15 @@ function ImageRenderer({tnode}: CustomRendererProps<TBlock>) {
return;
}
return onShowContextMenu(() =>
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived)),
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, isReportArchived),
originalReportID,
),
);
}}
isNested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
const htmlAttribAccountID = tnode.attributes.accountid;
const personalDetails = usePersonalDetails();
const htmlAttributeAccountID = tnode.attributes.accountid;
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();

let accountID: number;
Expand Down Expand Up @@ -83,7 +83,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
return;
}
return onShowContextMenu(() =>
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived)),
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived), originalReportID),
);
}}
onPress={(event) => {
Expand Down
12 changes: 10 additions & 2 deletions src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();
const isLast = defaultRendererProps.renderIndex === defaultRendererProps.renderLength - 1;

Expand Down Expand Up @@ -63,7 +63,15 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
return showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived));
return showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, isReportArchived),
originalReportID,
);
});
}}
shouldUseHapticsOnLongPress
Expand Down
5 changes: 5 additions & 0 deletions src/components/ReportActionItem/MoneyRequestAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type MoneyRequestActionProps = {

/** Whether context menu should be shown on press */
shouldDisplayContextMenu?: boolean;

/** ID of the original report from which the given reportAction is first created */
originalReportID?: string;
};

function MoneyRequestAction({
Expand All @@ -82,6 +85,7 @@ function MoneyRequestAction({
style,
isWhisper = false,
shouldDisplayContextMenu = true,
originalReportID,
}: MoneyRequestActionProps) {
const {shouldOpenReportInRHP} = useReportActionItemState();
const {onPreviewPressed} = useReportActionItemActions();
Expand Down Expand Up @@ -186,6 +190,7 @@ function MoneyRequestAction({
isHovered={isHovered}
isWhisper={isWhisper}
shouldDisplayContextMenu={shouldDisplayContextMenu}
originalReportID={originalReportID}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function MoneyRequestReportPreviewContent({
shouldShowBorder = false,
onPress,
forwardedFSClass,
originalReportID,
}: MoneyRequestReportPreviewContentProps) {
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [chatReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`);
Expand Down Expand Up @@ -917,7 +918,7 @@ function MoneyRequestReportPreviewContent({
if (!shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive);
showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, false, originalReportID);
}}
shouldUseHapticsOnLongPress
style={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function MoneyRequestReportPreview({
onPaymentOptionsHide,
shouldDisplayContextMenu = true,
shouldShowBorder,
originalReportID,
}: MoneyRequestReportPreviewProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -148,6 +149,7 @@ function MoneyRequestReportPreview({
onPreviewPressed={openReportFromPreview}
shouldShowPayerAndReceiver={shouldShowPayerAndReceiver}
shouldHighlight={!!newTransactionIDs?.has(item.transactionID)}
originalReportID={originalReportID}
/>
);

Expand Down Expand Up @@ -180,6 +182,7 @@ function MoneyRequestReportPreview({
onPress={openReportFromPreview}
shouldShowBorder={shouldShowBorder}
forwardedFSClass={CONST.FULLSTORY.CLASS.UNMASK}
originalReportID={originalReportID}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type MoneyRequestReportPreviewProps = {

/** Whether to show a border to separate Reports Chat Item and Money Request Report Preview */
shouldShowBorder?: boolean;

/** ID of the original report from which the given reportAction is first created */
originalReportID?: string;
};

type MoneyRequestReportPreviewContentOnyxProps = {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ReportActionItem/TaskPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Icon from '@components/Icon';
import {usePersonalDetails} from '@components/OnyxListItemProvider';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import RenderHTML from '@components/RenderHTML';
import {showContextMenuForReport} from '@components/ShowContextMenuContext';
import {showContextMenuForReport, useShowContextMenuState} from '@components/ShowContextMenuContext';
import UserDetailsTooltip from '@components/UserDetailsTooltip';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
Expand Down Expand Up @@ -85,6 +85,7 @@ function TaskPreview({
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const theme = useTheme();
const {originalReportID} = useShowContextMenuState();
const taskReportID = taskReport?.reportID ?? action?.childReportID;
// Prefer the live task report name so offline title edits are reflected immediately.
const taskTitle = taskReport?.reportName ?? action?.childReportName ?? '';
Expand Down Expand Up @@ -145,7 +146,7 @@ function TaskPreview({
if (!shouldDisplayContextMenu) {
return;
}
return showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive);
return showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, false, originalReportID);
})
}
shouldUseHapticsOnLongPress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function TransactionPreview(props: TransactionPreviewProps) {
shouldHighlight,
reportPreviewAction,
contextAction,
originalReportID,
} = props;

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`);
Expand Down Expand Up @@ -71,11 +72,14 @@ function TransactionPreview(props: TransactionPreviewProps) {
const transactionDetails = getTransactionDetails(transaction);
const {amount: requestAmount, currency: requestCurrency} = transactionDetails ?? {};

const contextMenuReportID = contextAction ? chatReportID : reportID;
const contextMenuAction = contextAction ?? action;

const showContextMenu = (event: GestureResponderEvent) => {
if (!shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, contextMenuAnchor, contextAction ? chatReportID : reportID, contextAction ?? action, checkIfContextMenuActive);
showContextMenuForReport(event, contextMenuAnchor, contextMenuReportID, contextMenuAction, checkIfContextMenuActive, false, originalReportID);
};

const offlineWithFeedbackOnClose = useCallback(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/ReportActionItem/TransactionPreview/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type TransactionPreviewProps = {

/** Whether the item should be highlighted */
shouldHighlight?: boolean;

/** ID of the original report from which the given reportAction is first created */
originalReportID?: string;
};

type TransactionPreviewContentProps = {
Expand Down
7 changes: 6 additions & 1 deletion src/components/ReportActionItem/TripRoomPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type TripRoomPreviewProps = {
/** Whether the corresponding report action item is hovered */
isHovered?: boolean;

/** ID of the original report from which the given reportAction is first created */
originalReportID?: string;

/** Whether context menu should be shown on press */
shouldDisplayContextMenu?: boolean;
};
Expand Down Expand Up @@ -123,6 +126,7 @@ function TripRoomPreview({
isHovered = false,
checkIfContextMenuActive = () => {},
shouldDisplayContextMenu = true,
originalReportID,
}: TripRoomPreviewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -172,9 +176,10 @@ function TripRoomPreview({
if (!shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive);
showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive, false, originalReportID);
}}
shouldUseHapticsOnLongPress
sentryLabel={CONST.SENTRY_LABEL.TRIP_ROOM_PREVIEW.CARD}
style={[styles.flexRow, styles.justifyContentBetween, styles.reportPreviewBox]}
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('iou.viewDetails')}
Expand Down
1 change: 1 addition & 0 deletions src/components/ShowContextMenuContext/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const defaultShowContextMenuStateContextValue: ShowContextMenuStateContextType =
transactionThreadReport: undefined,
isDisabled: true,
shouldDisplayContextMenu: true,
originalReportID: undefined,
};

const defaultShowContextMenuActionsContextValue: ShowContextMenuActionsContextType = {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ShowContextMenuContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {createContext, useContext} from 'react';
import type {GestureResponderEvent} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import {getOriginalReportID} from '@libs/ReportUtils';
import {showContextMenu} from '@pages/inbox/report/ContextMenu/ReportActionContextMenu';
import type {ContextMenuAnchor} from '@pages/inbox/report/ContextMenu/ReportActionContextMenu';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -31,6 +30,7 @@ function useShowContextMenuActions(): ShowContextMenuActionsContextType {
* @param action - ReportAction for ContextMenu
* @param checkIfContextMenuActive Callback to update context menu active state
* @param isArchivedRoom - Is the report an archived room
* @param originalReportID - ID of the original report from which the given reportAction is first created
*/
function showContextMenuForReport(
event: GestureResponderEvent | MouseEvent,
Expand All @@ -39,6 +39,7 @@ function showContextMenuForReport(
action: OnyxEntry<ReportAction>,
checkIfContextMenuActive: () => void,
isArchivedRoom = false,
originalReportID?: string,
) {
if (!canUseTouchScreen()) {
return;
Expand All @@ -51,7 +52,7 @@ function showContextMenuForReport(
contextMenuAnchor: anchor,
report: {
reportID,
originalReportID: reportID ? getOriginalReportID(reportID, action, undefined) : undefined,
originalReportID: originalReportID ?? reportID,
isArchivedRoom,
},
reportAction: {
Expand Down
1 change: 1 addition & 0 deletions src/components/ShowContextMenuContext/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ShowContextMenuStateContextType = {
transactionThreadReport?: OnyxEntry<Report>;
isDisabled: boolean;
shouldDisplayContextMenu?: boolean;
originalReportID?: string;
};

type ShowContextMenuActionsContextType = {
Expand Down
12 changes: 10 additions & 2 deletions src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type VideoPlayerThumbnailProps = {
function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel, isDeleted}: VideoPlayerThumbnailProps) {
const styles = useThemeStyles();
const icons = useMemoizedLazyExpensifyIcons(['Play'] as const);
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu} = useShowContextMenuState();
const {anchor, report, isReportArchived, action, isDisabled, shouldDisplayContextMenu, originalReportID} = useShowContextMenuState();
const {onShowContextMenu, checkIfContextMenuActive} = useShowContextMenuActions();

return (
Expand Down Expand Up @@ -59,7 +59,15 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel, isDele
return;
}
onShowContextMenu(() => {
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, isReportArchived));
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, isReportArchived),
originalReportID,
);
});
}}
shouldUseHapticsOnLongPress
Expand Down
9 changes: 7 additions & 2 deletions src/pages/inbox/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function PureReportActionItem({
clearError(transactionID);
}
clearAllRelatedReportActionErrors(reportID, action, originalReportID);
}, [action, isSendingMoney, reportID, clearAllRelatedReportActionErrors, report, chatReport, clearError]);
}, [action, isSendingMoney, reportID, clearAllRelatedReportActionErrors, report, chatReport, clearError, originalReportID]);

const showDismissReceiptErrorModal = useCallback(async () => {
const result = await showConfirmModal({
Expand Down Expand Up @@ -835,8 +835,9 @@ function PureReportActionItem({
transactionThreadReport,
isDisabled: false,
shouldDisplayContextMenu: shouldDisplayContextMenuValue,
originalReportID,
}),
[report, action, transactionThreadReport, shouldDisplayContextMenuValue, isReportArchived],
[report, action, transactionThreadReport, shouldDisplayContextMenuValue, isReportArchived, originalReportID],
);

const contextMenuActionsValue = useMemo(
Expand Down Expand Up @@ -1176,6 +1177,7 @@ function PureReportActionItem({
style={displayAsGroup ? [] : [styles.mt2]}
isWhisper={isWhisper}
shouldDisplayContextMenu={shouldDisplayContextMenuValue}
originalReportID={originalReportID}
/>
);

Expand Down Expand Up @@ -1220,6 +1222,7 @@ function PureReportActionItem({
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(action.childReportID, undefined, undefined, Navigation.getActiveRoute()));
}}
isTrackExpense={isTrackExpenseActionReportActionsUtils(action)}
originalReportID={originalReportID}
/>
</View>
);
Expand All @@ -1238,6 +1241,7 @@ function PureReportActionItem({
containerStyles={displayAsGroup ? [] : [styles.mt2]}
checkIfContextMenuActive={toggleContextMenuFromActiveReportAction}
shouldDisplayContextMenu={shouldDisplayContextMenuValue}
originalReportID={originalReportID}
/>
);
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && isClosedExpenseReportWithNoExpenses) {
Expand All @@ -1257,6 +1261,7 @@ function PureReportActionItem({
onPaymentOptionsHide={() => setIsPaymentMethodPopoverActive(false)}
shouldDisplayContextMenu={shouldDisplayContextMenuValue}
shouldShowBorder={shouldShowBorder}
originalReportID={originalReportID}
/>
);
} else if (isTaskAction(action)) {
Expand Down
Loading
Loading