Skip to content

Commit 1d7e6ef

Browse files
authored
Merge pull request Expensify#67242 from daledah/fix/66871
2 parents e3aab61 + d58f752 commit 1d7e6ef

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/components/BookTravelButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import CONST from '@src/CONST';
1717
import ONYXKEYS from '@src/ONYXKEYS';
1818
import ROUTES from '@src/ROUTES';
1919
import {isEmptyObject} from '@src/types/utils/EmptyObject';
20+
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
2021
import Button from './Button';
2122
import ConfirmModal from './ConfirmModal';
2223
import DotIndicatorMessage from './DotIndicatorMessage';
@@ -48,10 +49,11 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
4849
const styles = useThemeStyles();
4950
const StyleUtils = useStyleUtils();
5051
const {translate} = useLocalize();
51-
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false});
52+
const [activePolicyID, activePolicyIDMetadata] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
5253
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
5354
const isUserValidated = account?.validated ?? false;
5455
const primaryLogin = account?.primaryLogin ?? '';
56+
const isLoading = isLoadingOnyxValue(activePolicyIDMetadata);
5557

5658
const policy = usePolicy(activePolicyID);
5759
const [errorMessage, setErrorMessage] = useState<string | ReactElement>('');
@@ -172,6 +174,8 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
172174
onPress={bookATrip}
173175
accessibilityLabel={translate('travel.bookTravel')}
174176
style={styles.w100}
177+
isLoading={isLoading}
178+
isDisabled={!isLoading && !activePolicyID}
175179
success
176180
large
177181
/>

0 commit comments

Comments
 (0)