Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo defaults values for onyx ids PureReportActionItem #55536

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
aaee1f0
testing
kubabutkiewicz Jan 16, 2025
66b127b
revert testing change
kubabutkiewicz Jan 16, 2025
07ad5f1
testing change
kubabutkiewicz Jan 16, 2025
7acaffb
undo defaults in PureReportActionItem
kubabutkiewicz Jan 17, 2025
b5213ef
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 17, 2025
cef24c6
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 20, 2025
f855fe9
continue fixing lint errors
kubabutkiewicz Jan 20, 2025
c51d608
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 20, 2025
98566a1
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 21, 2025
e9f4936
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 21, 2025
84d6eb5
fix rest of the lint issues
kubabutkiewicz Jan 21, 2025
3e1a2dc
resolve lint issues and comments
kubabutkiewicz Jan 22, 2025
7b468bc
fix reportactionitem
kubabutkiewicz Jan 22, 2025
5a808ec
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 22, 2025
90a9438
fix lint
kubabutkiewicz Jan 22, 2025
1648be5
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 23, 2025
64f7c01
removed unwanted changed
kubabutkiewicz Jan 23, 2025
f598ca7
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 23, 2025
968912b
fix: resolve comments
kubabutkiewicz Jan 23, 2025
e6bbf3a
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 23, 2025
b4870ba
fix: resolve comment form Report.ts file
kubabutkiewicz Jan 23, 2025
276ed0b
fixes
kubabutkiewicz Jan 23, 2025
1ab69c3
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 24, 2025
6479ec5
added early returns
kubabutkiewicz Jan 24, 2025
2305ac7
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 24, 2025
8eb529d
fix type in TripRoomPreview
kubabutkiewicz Jan 24, 2025
1f1a7e1
resolve comments
kubabutkiewicz Jan 27, 2025
778ad98
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 27, 2025
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
22 changes: 16 additions & 6 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ const ROUTES = {
},
EDIT_REPORT_FIELD_REQUEST: {
route: 'r/:reportID/edit/policyField/:policyID/:fieldID',
getRoute: (reportID: string, policyID: string | undefined, fieldID: string, backTo?: string) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the EDIT_REPORT_FIELD_REQUEST route');
getRoute: (reportID: string | undefined, policyID: string | undefined, fieldID: string, backTo?: string) => {
if (!policyID || !reportID) {
Log.warn('Invalid policyID or reportID is used to build the EDIT_REPORT_FIELD_REQUEST route');
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
}
return getUrlWithBackToParam(`r/${reportID}/edit/policyField/${policyID}/${encodeURIComponent(fieldID)}` as const, backTo);
},
Expand Down Expand Up @@ -404,11 +404,21 @@ const ROUTES = {
},
SPLIT_BILL_DETAILS: {
route: 'r/:reportID/split/:reportActionID',
getRoute: (reportID: string, reportActionID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/split/${reportActionID}` as const, backTo),
getRoute: (reportID: string | undefined, reportActionID: string, backTo?: string) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the SPLIT_BILL_DETAILS route');
}
return getUrlWithBackToParam(`r/${reportID}/split/${reportActionID}` as const, backTo);
},
},
TASK_TITLE: {
route: 'r/:reportID/title',
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/title` as const, backTo),
getRoute: (reportID: string | undefined, backTo?: string) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the TASK_TITLE route');
}
return getUrlWithBackToParam(`r/${reportID}/title` as const, backTo);
},
},
REPORT_DESCRIPTION: {
route: 'r/:reportID/description',
Expand Down Expand Up @@ -1918,7 +1928,7 @@ const ROUTES = {
},
DEBUG_REPORT: {
route: 'debug/report/:reportID',
getRoute: (reportID: string) => `debug/report/${reportID}` as const,
getRoute: (reportID: string | undefined) => `debug/report/${reportID}` as const,
},
DEBUG_REPORT_TAB_DETAILS: {
route: 'debug/report/:reportID/details',
Expand Down
4 changes: 0 additions & 4 deletions src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
description={Str.UCFirst(reportField.name)}
title={fieldValue}
onPress={() => {
if (!report?.reportID) {
return;
}

Navigation.navigate(
ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report?.reportID, report?.policyID, reportField.fieldID, Navigation.getReportRHPActiveRoute()),
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
);
Expand Down
9 changes: 2 additions & 7 deletions src/components/ReportActionItem/MoneyRequestAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,11 @@ function MoneyRequestAction({

const onMoneyRequestPreviewPressed = () => {
if (isSplitBillAction) {
if (!chatReportID) {
return;
}
const reportActionID = action.reportActionID;
Navigation.navigate(ROUTES.SPLIT_BILL_DETAILS.getRoute(chatReportID, reportActionID, Navigation.getReportRHPActiveRoute()));
Navigation.navigate(ROUTES.SPLIT_BILL_DETAILS.getRoute(chatReportID, action.reportActionID, Navigation.getReportRHPActiveRoute()));
return;
}

const childReportID = action?.childReportID;
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID));
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(action?.childReportID));
};

let shouldShowPendingConversionMessage = false;
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ function TaskView({report}: TaskViewProps) {
{(hovered) => (
<PressableWithSecondaryInteraction
onPress={checkIfActionIsAllowed((e) => {
if (isDisableInteractive || !report?.reportID) {
if (isDisableInteractive) {
return;
}
if (e && e.type === 'click') {
(e.currentTarget as HTMLElement).blur();
}

Navigation.navigate(ROUTES.TASK_TITLE.getRoute(report.reportID, Navigation.getReportRHPActiveRoute()));
Navigation.navigate(ROUTES.TASK_TITLE.getRoute(report?.reportID, Navigation.getReportRHPActiveRoute()));
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
})}
style={({pressed}) => [
styles.ph5,
Expand Down
5 changes: 2 additions & 3 deletions src/components/ReportActionItem/TripRoomPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {convertToDisplayString} from '@libs/CurrencyUtils';
import DateUtils from '@libs/DateUtils';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import Navigation from '@libs/Navigation/Navigation';
import {getMoneyRequestSpendBreakdown, getTripTransactions} from '@libs/ReportUtils';
import {getMoneyRequestSpendBreakdown} from '@libs/ReportUtils';
import type {ReservationData} from '@libs/TripReservationUtils';
import {getReservationsFromTripTransactions, getTripReservationIcon} from '@libs/TripReservationUtils';
import type {ContextMenuAnchor} from '@pages/home/report/ContextMenu/ReportActionContextMenu';
Expand Down Expand Up @@ -120,7 +120,6 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReport?.iouReportID}`);
const tripTransactions = useTripTransactions(chatReportID);

const tripTransactions = getTripTransactions(chatReport?.reportID);
const reservationsData: ReservationData[] = getReservationsFromTripTransactions(tripTransactions);
const dateInfo = chatReport?.tripData ? DateUtils.getFormattedDateRange(new Date(chatReport.tripData.startDate), new Date(chatReport.tripData.endDate)) : '';
const {totalDisplaySpend} = getMoneyRequestSpendBreakdown(chatReport);
Expand All @@ -132,7 +131,7 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch
}

return convertToDisplayString(
tripTransactions.reduce((acc, transaction) => acc + Math.abs(transaction.amount), 0),
tripTransactions?.reduce((acc, transaction) => acc + Math.abs(transaction.amount), 0),
currency,
);
}, [currency, totalDisplaySpend, tripTransactions]);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Policy/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,10 +875,10 @@ function setWorkspaceInviteMembersDraft(policyID: string, invitedEmailsToAccount
* Accept user join request to a workspace
*/
function acceptJoinRequest(reportID: string | undefined, reportAction: OnyxEntry<ReportAction>) {
const choice = CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT;
if (!reportAction) {
return;
}
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
const choice = CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT;

const optimisticData: OnyxUpdate[] = [
{
Expand Down
14 changes: 6 additions & 8 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1753,12 +1753,11 @@ function handleUserDeletedLinksInHtml(newCommentText: string, originalCommentMar
/** Saves a new message for a comment. Marks the comment as edited, which will be reflected in the UI. */
function editReportComment(reportID: string | undefined, originalReportAction: OnyxEntry<ReportAction>, textForNewComment: string, videoAttributeCache?: Record<string, string>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not return early if !reportID here and in the functions below?

Copy link
Contributor Author

@kubabutkiewicz kubabutkiewicz Jan 23, 2025

Choose a reason for hiding this comment

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

When I do this the the TS will complain about this

const parameters: UpdateCommentParams = {
        reportID: originalReportID,
        reportComment: htmlForNewComment,
        reportActionID,
    };

as originalReportID is of type string | undefined and UpdateCommentParams expect reportID will be of type string but when I do this

if (!originalReportID || !originalReportAction) {
        return;
    }

everything looks good

const originalReportID = getOriginalReportID(reportID, originalReportAction);
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`];
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report);

if (!originalReportID || !originalReportAction) {
return;
}
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`];
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report);

// Do not autolink if someone explicitly tries to remove a link from message.
// https://github.com/Expensify/App/issues/9090
Expand Down Expand Up @@ -2494,17 +2493,16 @@ function addPolicyReport(policyReport: OptimisticChatReport) {

/** Deletes a report, along with its reportActions, any linked reports, and any linked IOU report. */
function deleteReport(reportID: string | undefined, shouldDeleteChildReports = false) {
if (!reportID) {
Log.warn('[Report] deleteReport called with no reportID');
return;
}
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const onyxData: Record<string, null> = {
[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]: null,
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]: null,
};

if (!reportID) {
Log.warn('[Report] deleteReport called with no reportID');
return;
}

// Delete linked transactions
const reportActionsForReport = allReportActions?.[reportID];

Expand Down
4 changes: 0 additions & 4 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,6 @@ const ContextMenuActions: ContextMenuAction[] = [
icon: Expensicons.Bug,
shouldShow: ({type, user}) => type === CONST.CONTEXT_MENU_TYPES.REPORT && !!user?.isDebugModeEnabled,
onPress: (closePopover, {reportID}) => {
if (!reportID) {
return;
}

Navigation.navigate(ROUTES.DEBUG_REPORT.getRoute(reportID));
hideContextMenu(false, ReportActionComposeFocusManager.focus);
},
Expand Down
Loading