Skip to content

Commit

Permalink
Merge pull request Expensify#51440 from Expensify/scott-fixConsoleError
Browse files Browse the repository at this point in the history
Do not set optimistic nvp_onboarding for invited users
  • Loading branch information
cristipaval authored Nov 16, 2024
2 parents 99bf554 + 635ffc5 commit 9774032
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
13 changes: 12 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7367,7 +7367,18 @@ function completePaymentOnboarding(paymentSelected: ValueOf<typeof CONST.PAYMENT
onboardingPurpose = CONST.ONBOARDING_CHOICES.CHAT_SPLIT;
}

Report.completeOnboarding(onboardingPurpose, CONST.ONBOARDING_MESSAGES[onboardingPurpose], personalDetails?.firstName ?? '', personalDetails?.lastName ?? '', paymentSelected);
Report.completeOnboarding(
onboardingPurpose,
CONST.ONBOARDING_MESSAGES[onboardingPurpose],
personalDetails?.firstName ?? '',
personalDetails?.lastName ?? '',
undefined,
undefined,
paymentSelected,
undefined,
undefined,
true,
);
}

function payMoneyRequest(paymentType: PaymentMethodType, chatReport: OnyxTypes.Report, iouReport: OnyxEntry<OnyxTypes.Report>, full = true) {
Expand Down
20 changes: 14 additions & 6 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3478,6 +3478,7 @@ function prepareOnboardingOptimisticData(
adminsChatReportID?: string,
onboardingPolicyID?: string,
userReportedIntegration?: OnboardingAccounting,
wasInvited?: boolean,
) {
// If the user has the "combinedTrackSubmit" beta enabled we'll show different tasks for track and submit expense.
if (Permissions.canUseCombinedTrackSubmit()) {
Expand Down Expand Up @@ -3761,12 +3762,14 @@ function prepareOnboardingOptimisticData(
key: ONYXKEYS.NVP_INTRO_SELECTED,
value: {choice: engagementChoice},
},
{
);
if (!wasInvited) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {hasCompletedGuidedSetupFlow: true},
},
);
});
}

const successData: OnyxUpdate[] = [...tasksForSuccessData];
successData.push({
Expand Down Expand Up @@ -3821,12 +3824,15 @@ function prepareOnboardingOptimisticData(
key: ONYXKEYS.NVP_INTRO_SELECTED,
value: {choice: null},
},
{
);

if (!wasInvited) {
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {hasCompletedGuidedSetupFlow: false},
},
);
});
}

if (userReportedIntegration) {
optimisticData.push({
Expand Down Expand Up @@ -3910,13 +3916,15 @@ function completeOnboarding(
paymentSelected?: string,
companySize?: OnboardingCompanySize,
userReportedIntegration?: OnboardingAccounting,
wasInvited?: boolean,
) {
const {optimisticData, successData, failureData, guidedSetupData, actorAccountID} = prepareOnboardingOptimisticData(
engagementChoice,
data,
adminsChatReportID,
onboardingPolicyID,
userReportedIntegration,
wasInvited,
);

const parameters: CompleteGuidedSetupParams = {
Expand Down

0 comments on commit 9774032

Please sign in to comment.