Skip to content

Commit

Permalink
fix: eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszGrajdek committed Feb 11, 2025
1 parent 4cb6e96 commit 59900cf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1579,11 +1579,11 @@ function handleReportChanged(report: OnyxEntry<Report>) {
}

/** Deletes a comment from the report, basically sets it as empty string */
function deleteReportComment(reportID: string, reportAction: ReportAction) {
function deleteReportComment(reportID: string | undefined, reportAction: ReportAction) {
const originalReportID = getOriginalReportID(reportID, reportAction);
const reportActionID = reportAction.reportActionID;

if (!reportActionID || !originalReportID) {
if (!reportActionID || !originalReportID || !reportID) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type BaseReportActionContextMenuProps = {
reportID: string | undefined;

/** The ID of the report action this context menu is attached to. */
reportActionID: string;
reportActionID: string | undefined;

/** The ID of the original report from which the given reportAction is first created. */
// originalReportID is used in withOnyx to get the reportActions for the original report
Expand Down Expand Up @@ -152,7 +152,7 @@ function BaseReportActionContextMenu({
const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`);

const reportAction: OnyxEntry<ReportAction> = useMemo(() => {
if (isEmptyObject(reportActions) || reportActionID === '0' || reportActionID === '-1') {
if (isEmptyObject(reportActions) || !reportActionID || reportActionID === '0' || reportActionID === '-1') {
return;
}
return reportActions[reportActionID];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import ConfirmModal from '@components/ConfirmModal';
import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent';
import useLocalize from '@hooks/useLocalize';
import calculateAnchorPosition from '@libs/calculateAnchorPosition';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as IOU from '@userActions/IOU';
import * as Report from '@userActions/Report';
import {getOriginalMessage, isMoneyRequestAction, isTrackExpenseAction} from '@libs/ReportActionsUtils';
import {deleteMoneyRequest, deleteTrackExpense} from '@userActions/IOU';
import {deleteReportComment} from '@userActions/Report';
import type {AnchorDimensions} from '@src/styles';
import type {ReportAction} from '@src/types/onyx';
import BaseReportActionContextMenu from './BaseReportActionContextMenu';
Expand All @@ -33,11 +33,11 @@ function extractPointerEvent(event: GestureResponderEvent | MouseEvent): MouseEv

function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<ReportActionContextMenu>) {
const {translate} = useLocalize();
const reportIDRef = useRef('-1');
const reportIDRef = useRef<string>();
const typeRef = useRef<ContextMenuType>();
const reportActionRef = useRef<NonNullable<OnyxEntry<ReportAction>> | null>(null);
const reportActionIDRef = useRef('-1');
const originalReportIDRef = useRef('-1');
const reportActionIDRef = useRef<string>();
const originalReportIDRef = useRef<string>();
const selectionRef = useRef('');
const reportActionDraftMessageRef = useRef<string>();

Expand Down Expand Up @@ -211,10 +211,10 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
}).then(() => {
setDisabledActions(disabledOptions);
typeRef.current = type;
reportIDRef.current = reportID ?? '-1';
reportActionIDRef.current = reportActionID ?? '-1';
reportIDRef.current = reportID;
reportActionIDRef.current = reportActionID;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
originalReportIDRef.current = originalReportID || '-1';
originalReportIDRef.current = originalReportID;
selectionRef.current = selection;
setIsPopoverVisible(true);
reportActionDraftMessageRef.current = draftMessage;
Expand Down Expand Up @@ -270,15 +270,15 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
const confirmDeleteAndHideModal = useCallback(() => {
callbackWhenDeleteModalHide.current = runAndResetCallback(onConfirmDeleteModal.current);
const reportAction = reportActionRef.current;
if (ReportActionsUtils.isMoneyRequestAction(reportAction)) {
const originalMessage = ReportActionsUtils.getOriginalMessage(reportAction);
if (ReportActionsUtils.isTrackExpenseAction(reportAction)) {
IOU.deleteTrackExpense(reportIDRef.current, originalMessage?.IOUTransactionID ?? '-1', reportAction);
if (isMoneyRequestAction(reportAction)) {
const originalMessage = getOriginalMessage(reportAction);
if (isTrackExpenseAction(reportAction)) {
deleteTrackExpense(reportIDRef.current, originalMessage?.IOUTransactionID, reportAction);
} else {
IOU.deleteMoneyRequest(originalMessage?.IOUTransactionID ?? '-1', reportAction);
deleteMoneyRequest(originalMessage?.IOUTransactionID, reportAction);
}
} else if (reportAction) {
Report.deleteReportComment(reportIDRef.current, reportAction);
deleteReportComment(reportIDRef.current, reportAction);
}

DeviceEventEmitter.emit(`deletedReportAction_${reportIDRef.current}`, reportAction?.reportActionID);
Expand Down

0 comments on commit 59900cf

Please sign in to comment.