From b01c88f2bfc7bde54df0b2924fdb56176180dab0 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 28 Jul 2025 19:05:08 +0700 Subject: [PATCH 1/3] fix: canBeMissing nvp_expensify_activePolicyID --- src/components/BookTravelButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BookTravelButton.tsx b/src/components/BookTravelButton.tsx index 5df89fdb1450..222f276f01c6 100644 --- a/src/components/BookTravelButton.tsx +++ b/src/components/BookTravelButton.tsx @@ -48,7 +48,7 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); - const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false}); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); const isUserValidated = account?.validated ?? false; const primaryLogin = account?.primaryLogin ?? ''; From 0138a1ffcd5cd9f4f3be4ea8552f390a91200131 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 4 Aug 2025 16:32:47 +0700 Subject: [PATCH 2/3] feat: add loading state for book travel button --- src/components/BookTravelButton.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/BookTravelButton.tsx b/src/components/BookTravelButton.tsx index 222f276f01c6..a9dc32c9d21c 100644 --- a/src/components/BookTravelButton.tsx +++ b/src/components/BookTravelButton.tsx @@ -17,6 +17,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import Button from './Button'; import ConfirmModal from './ConfirmModal'; import DotIndicatorMessage from './DotIndicatorMessage'; @@ -48,10 +49,11 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); - const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); + const [activePolicyID, activePolicyIDMetadata] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); const isUserValidated = account?.validated ?? false; const primaryLogin = account?.primaryLogin ?? ''; + const isLoading = isLoadingOnyxValue(activePolicyIDMetadata); const policy = usePolicy(activePolicyID); const [errorMessage, setErrorMessage] = useState(''); @@ -172,6 +174,8 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se onPress={bookATrip} accessibilityLabel={translate('travel.bookTravel')} style={styles.w100} + isLoading={isLoading} + isDisabled={!isLoading && activePolicyID} success large /> From db9f5b28feb1137d9d14601d27fe7cd6938ce31e Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 5 Aug 2025 08:25:03 +0700 Subject: [PATCH 3/3] fix: incorrect value --- src/components/BookTravelButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BookTravelButton.tsx b/src/components/BookTravelButton.tsx index a9dc32c9d21c..c757fc41e209 100644 --- a/src/components/BookTravelButton.tsx +++ b/src/components/BookTravelButton.tsx @@ -175,7 +175,7 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se accessibilityLabel={translate('travel.bookTravel')} style={styles.w100} isLoading={isLoading} - isDisabled={!isLoading && activePolicyID} + isDisabled={!isLoading && !activePolicyID} success large />