Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Held requests] Hold Request education modal reappears after relogin #40435

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ const ONYXKEYS = {
/** Whether the user has tried focus mode yet */
NVP_TRY_FOCUS_MODE: 'nvp_tryFocusMode',

/** Whether the user has been shown the hold educational interstitial yet */
NVP_HOLD_USE_EXPLAINED: 'holdUseExplained',
/** Whether the user has dismissed the hold educational interstitial */
DISMISSED_HOLD_USE_EXPLANATION: 'dismissedholdUseExplanation',

/** Store preferred skintone for emoji */
PREFERRED_EMOJI_SKIN_TONE: 'nvp_expensify_preferredEmojiSkinTone',
Expand Down Expand Up @@ -595,7 +595,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE]: OnyxTypes.BlockedFromConcierge;
[ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID]: string;
[ONYXKEYS.NVP_TRY_FOCUS_MODE]: boolean;
[ONYXKEYS.NVP_HOLD_USE_EXPLAINED]: boolean;
[ONYXKEYS.DISMISSED_HOLD_USE_EXPLANATION]: boolean;
[ONYXKEYS.FOCUS_MODE_NOTIFICATION]: boolean;
[ONYXKEYS.NVP_LAST_PAYMENT_METHOD]: OnyxTypes.LastPaymentMethod;
[ONYXKEYS.NVP_RECENT_WAYPOINTS]: OnyxTypes.RecentWaypoint[];
Expand Down
18 changes: 9 additions & 9 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type MoneyRequestHeaderOnyxProps = {
parentReportActions: OnyxEntry<ReportActions>;

/** Whether we should show the Hold Interstitial explaining the feature */
shownHoldUseExplanation: OnyxEntry<boolean>;
dismissedholdUseExplanation: OnyxEntry<boolean>;
};

type MoneyRequestHeaderProps = MoneyRequestHeaderOnyxProps & {
Expand All @@ -52,7 +52,7 @@ type MoneyRequestHeaderProps = MoneyRequestHeaderOnyxProps & {
parentReportAction: OnyxEntry<ReportAction>;
};

function MoneyRequestHeader({session, parentReport, report, parentReportAction, transaction, shownHoldUseExplanation = false, policy}: MoneyRequestHeaderProps) {
function MoneyRequestHeader({session, parentReport, report, parentReportAction, transaction, dismissedholdUseExplanation = false, policy}: MoneyRequestHeaderProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
Expand Down Expand Up @@ -132,8 +132,8 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,
}

useEffect(() => {
setShouldShowHoldMenu(isOnHold && !shownHoldUseExplanation);
}, [isOnHold, shownHoldUseExplanation]);
setShouldShowHoldMenu(isOnHold && !dismissedholdUseExplanation);
}, [isOnHold, dismissedholdUseExplanation]);

useEffect(() => {
if (!shouldShowHoldMenu) {
Expand All @@ -150,7 +150,7 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,
}, [isSmallScreenWidth, shouldShowHoldMenu]);

const handleHoldRequestClose = () => {
IOU.setShownHoldUseExplanation();
IOU.dismissHoldUseExplanation();
};

if (canDeleteRequest) {
Expand Down Expand Up @@ -218,20 +218,20 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,

MoneyRequestHeader.displayName = 'MoneyRequestHeader';

const MoneyRequestHeaderWithTransaction = withOnyx<MoneyRequestHeaderProps, Pick<MoneyRequestHeaderOnyxProps, 'transaction' | 'shownHoldUseExplanation'>>({
const MoneyRequestHeaderWithTransaction = withOnyx<MoneyRequestHeaderProps, Pick<MoneyRequestHeaderOnyxProps, 'transaction' | 'dismissedholdUseExplanation'>>({
transaction: {
key: ({report, parentReportActions}) => {
const parentReportAction = (report.parentReportActionID && parentReportActions ? parentReportActions[report.parentReportActionID] : {}) as ReportAction & OriginalMessageIOU;
return `${ONYXKEYS.COLLECTION.TRANSACTION}${parentReportAction?.originalMessage?.IOUTransactionID ?? 0}`;
},
},
shownHoldUseExplanation: {
key: ONYXKEYS.NVP_HOLD_USE_EXPLAINED,
dismissedholdUseExplanation: {
key: ONYXKEYS.DISMISSED_HOLD_USE_EXPLANATION,
initWithStoredValues: true,
},
})(MoneyRequestHeader);

export default withOnyx<Omit<MoneyRequestHeaderProps, 'transaction' | 'shownHoldUseExplanation'>, Omit<MoneyRequestHeaderOnyxProps, 'transaction' | 'shownHoldUseExplanation'>>({
export default withOnyx<Omit<MoneyRequestHeaderProps, 'transaction' | 'dismissedholdUseExplanation'>, Omit<MoneyRequestHeaderOnyxProps, 'transaction' | 'dismissedholdUseExplanation'>>({
session: {
key: ONYXKEYS.SESSION,
},
Expand Down
22 changes: 19 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
ReplaceReceiptParams,
RequestMoneyParams,
SendMoneyParams,
SetNameValuePairParams,
SplitBillParams,
StartSplitBillParams,
SubmitReportParams,
Expand Down Expand Up @@ -5839,8 +5840,23 @@ function setMoneyRequestParticipants(participants: Participant[], isSplitRequest
Onyx.merge(ONYXKEYS.IOU, {participants, isSplitRequest});
}

function setShownHoldUseExplanation() {
Onyx.set(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, true);
function dismissHoldUseExplanation() {
const parameters: SetNameValuePairParams = {
name: ONYXKEYS.DISMISSED_HOLD_USE_EXPLANATION,
value: true,
};

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.DISMISSED_HOLD_USE_EXPLANATION,
value: true,
},
];

API.write(WRITE_COMMANDS.SET_NAME_VALUE_PAIR, parameters, {
optimisticData,
});
}

/**
Expand Down Expand Up @@ -6036,7 +6052,7 @@ export {
setMoneyRequestTag,
setMoneyRequestTaxAmount,
setMoneyRequestTaxRate,
setShownHoldUseExplanation,
dismissHoldUseExplanation,
updateMoneyRequestDate,
updateMoneyRequestBillable,
updateMoneyRequestMerchant,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProcessMoneyRequestHoldPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function ProcessMoneyRequestHoldPage() {
const {translate} = useLocalize();

const onConfirm = useCallback(() => {
IOU.setShownHoldUseExplanation();
IOU.dismissHoldUseExplanation();
Navigation.goBack();
}, []);

cdOut marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading