From 5fd1a146d20e5229c8e24ae4e7098033b5f850c4 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 30 May 2024 16:10:54 +0800 Subject: [PATCH 1/3] fix wrong config --- src/components/MoneyRequestHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 33b47aafa15c..f34ebb132ad8 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -52,7 +52,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${(parentReportAction as ReportAction & OriginalMessageIOU)?.originalMessage?.IOUTransactionID ?? 0}`); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); const [session] = useOnyx(ONYXKEYS.SESSION); - const [shownHoldUseExplanation] = useOnyx(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, {initWithStoredValues: false}); + const [shownHoldUseExplanation] = useOnyx(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, {initialValue: false}); const styles = useThemeStyles(); const theme = useTheme(); From 4130de79fa52be513be6c04825bd98c675c70467 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 30 May 2024 17:06:19 +0800 Subject: [PATCH 2/3] wait until hold use explained onyx data is loaded before showing the hold education modal --- src/components/MoneyRequestHeader.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index f34ebb132ad8..362cab556bef 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -29,6 +29,7 @@ import * as Expensicons from './Icon/Expensicons'; import type {MoneyRequestHeaderStatusBarProps} from './MoneyRequestHeaderStatusBar'; import MoneyRequestHeaderStatusBar from './MoneyRequestHeaderStatusBar'; import ProcessMoneyRequestHoldMenu from './ProcessMoneyRequestHoldMenu'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; type MoneyRequestHeaderProps = { /** The report currently being looked at */ @@ -52,7 +53,8 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${(parentReportAction as ReportAction & OriginalMessageIOU)?.originalMessage?.IOUTransactionID ?? 0}`); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); const [session] = useOnyx(ONYXKEYS.SESSION); - const [shownHoldUseExplanation] = useOnyx(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, {initialValue: false}); + const [holdUseExplained, holdUseExplainedResult] = useOnyx(ONYXKEYS.NVP_HOLD_USE_EXPLAINED); + const isLoadingHoldUseExplained = isLoadingOnyxValue(holdUseExplainedResult); const styles = useThemeStyles(); const theme = useTheme(); @@ -171,8 +173,11 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow } useEffect(() => { - setShouldShowHoldMenu(isOnHold && !shownHoldUseExplanation); - }, [isOnHold, shownHoldUseExplanation]); + if (isLoadingHoldUseExplained) { + return; + } + setShouldShowHoldMenu(isOnHold && !holdUseExplained); + }, [isOnHold, holdUseExplained, isLoadingHoldUseExplained]); useEffect(() => { if (!shouldShowHoldMenu) { From d888b3ac2e571d87b758667f107e926f74d148e5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 30 May 2024 17:07:17 +0800 Subject: [PATCH 3/3] prettier --- src/components/MoneyRequestHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 362cab556bef..05d976001768 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -21,6 +21,7 @@ import ROUTES from '@src/ROUTES'; import type {Policy, Report, ReportAction} from '@src/types/onyx'; import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage'; import type IconAsset from '@src/types/utils/IconAsset'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import Button from './Button'; import ConfirmModal from './ConfirmModal'; import HeaderWithBackButton from './HeaderWithBackButton'; @@ -29,7 +30,6 @@ import * as Expensicons from './Icon/Expensicons'; import type {MoneyRequestHeaderStatusBarProps} from './MoneyRequestHeaderStatusBar'; import MoneyRequestHeaderStatusBar from './MoneyRequestHeaderStatusBar'; import ProcessMoneyRequestHoldMenu from './ProcessMoneyRequestHoldMenu'; -import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; type MoneyRequestHeaderProps = { /** The report currently being looked at */