Skip to content

Commit

Permalink
Merge pull request #42819 from bernhardoj/fix/wrong-config
Browse files Browse the repository at this point in the history
Fix NVP_HOLD_USE_EXPLAINED useOnyx wrong config
  • Loading branch information
techievivek authored Jun 13, 2024
2 parents 1883f99 + d888b3a commit 9792bb0
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 @@ -22,6 +22,7 @@ import type {Route} 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';
Expand Down Expand Up @@ -53,7 +54,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, {initWithStoredValues: false});
const [holdUseExplained, holdUseExplainedResult] = useOnyx(ONYXKEYS.NVP_HOLD_USE_EXPLAINED);
const isLoadingHoldUseExplained = isLoadingOnyxValue(holdUseExplainedResult);

const styles = useThemeStyles();
const theme = useTheme();
Expand Down Expand Up @@ -175,8 +177,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 9792bb0

Please sign in to comment.