diff --git a/src/components/OfflineWithFeedback.tsx b/src/components/OfflineWithFeedback.tsx index c7d038888c39..7a0a8286f901 100644 --- a/src/components/OfflineWithFeedback.tsx +++ b/src/components/OfflineWithFeedback.tsx @@ -9,7 +9,7 @@ import shouldRenderOffscreen from '@libs/shouldRenderOffscreen'; import CONST from '@src/CONST'; import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; -import {isNotEmptyObject} from '@src/types/utils/EmptyObject'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import MessagesRow from './MessagesRow'; /** @@ -82,10 +82,10 @@ function OfflineWithFeedback({ const StyleUtils = useStyleUtils(); const {isOffline} = useNetwork(); - const hasErrors = isNotEmptyObject(errors ?? {}); + const hasErrors = !isEmptyObject(errors ?? {}); // Some errors have a null message. This is used to apply opacity only and to avoid showing redundant messages. const errorMessages = omitBy(errors, (e) => e === null); - const hasErrorMessages = isNotEmptyObject(errorMessages); + const hasErrorMessages = !isEmptyObject(errorMessages); const isOfflinePendingAction = !!isOffline && !!pendingAction; const isUpdateOrDeleteError = hasErrors && (pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE); const isAddError = hasErrors && pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8eb8efd09734..08e59327bbd6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2564,11 +2564,11 @@ function updateOptimisticParentReportAction(parentReportAction: OnyxEntry(WrappedComponent: // For small screen, we don't call openReport API when we go to a sub report page by deeplink // So we need to call openReport here for small screen useEffect(() => { - if (!props.isSmallScreenWidth || (isNotEmptyObject(props.report) && isNotEmptyObject(reportAction))) { + if (!props.isSmallScreenWidth || (!isEmptyObject(props.report) && !isEmptyObject(reportAction))) { return; } Report.openReport(props.route.params.reportID); diff --git a/src/types/utils/EmptyObject.ts b/src/types/utils/EmptyObject.ts index 48be674f3c5c..1d2a2ed6baec 100644 --- a/src/types/utils/EmptyObject.ts +++ b/src/types/utils/EmptyObject.ts @@ -1,17 +1,10 @@ -import type Falsy from './Falsy'; - type EmptyObject = Record; type EmptyValue = EmptyObject | null | undefined; -// eslint-disable-next-line rulesdir/no-negated-variables -function isNotEmptyObject | Falsy>(arg: T | EmptyObject): arg is NonNullable { - return Object.keys(arg ?? {}).length > 0; -} - function isEmptyObject(obj: T | EmptyValue): obj is EmptyValue { return Object.keys(obj ?? {}).length === 0; } -export {isNotEmptyObject, isEmptyObject}; +export {isEmptyObject}; export type {EmptyObject};