Skip to content

Commit

Permalink
wait until hold use explained onyx data is loaded before showing the …
Browse files Browse the repository at this point in the history
…hold education modal
  • Loading branch information
bernhardoj committed May 30, 2024
1 parent 5fd1a14 commit 4130de7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4130de7

Please sign in to comment.