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

[Guided Setup Stage 3] Update the Pay w/ Expensify selectors #45264

Merged

Conversation

cdOut
Copy link
Contributor

@cdOut cdOut commented Jul 11, 2024

Details

Added logic for sending onboarding messages through concierge after sign-in through a magic link sent via email for pay with expensify selectors (IOU / Invoice).

Fixed Issues

$ #45045
PROPOSAL:

Tests

Payment via VBBA:

  1. On the first account submit an expense
  2. To it as a recipient add an email that doesn't have an account made for it yet
  3. Submit it and then navigate to your emails
  4. Press on the magic link on the bottom of the message you've received inviting you to the expense
  5. When navigated into expensify on the new account, go into the expense and for payment choose Business Bank Account
  6. Confirm that the expense has been moved into the users workspace and a new message from Concierge was received with a task list that is read-only and an onboarding video appears

Payment via Elsewhere:

  1. On the first account submit an expense
  2. To it as a recipient add an email that doesn't have an account made for it yet
  3. Submit it and then navigate to your emails
  4. Press on the magic link on the bottom of the message you've received inviting you to the expense
  5. When navigated into expensify on the new account, go into the expense and for payment choose Elsewhere/PBA/Debit/Credit (All those cases should be handled in the same way)
  6. Confirm that a new message from Concierge was received with a task list that is read-only and an onboarding video appears
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

MacOS: Chrome / Safari

IOU / Invoice PBA

WEB.PBA.low.res.mov

IOU / Invoice BBA

WEB.BBA.low.res.mov

@cdOut cdOut changed the title [Guided Setup Stage 3] Update the Pay w/ Expensify selectors [WIP] [Guided Setup Stage 3] Update the Pay w/ Expensify selectors Jul 11, 2024
@cdOut cdOut changed the title [WIP] [Guided Setup Stage 3] Update the Pay w/ Expensify selectors [Guided Setup Stage 3] Update the Pay w/ Expensify selectors Jul 23, 2024
@cdOut cdOut marked this pull request as ready for review July 29, 2024 09:13
@cdOut cdOut requested a review from a team as a code owner July 29, 2024 09:13
@melvin-bot melvin-bot bot removed the request for review from a team July 29, 2024 09:13
Copy link

melvin-bot bot commented Jul 29, 2024

@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot requested a review from DylanDylann July 29, 2024 09:13
@DylanDylann
Copy link
Contributor

@cdOut Could you provide a video about the result?

@DylanDylann
Copy link
Contributor

@cdOut bump on this comment

@cdOut
Copy link
Contributor Author

cdOut commented Jul 31, 2024

@DylanDylann we're currently blocked with this as there is some problem with how the app functions when opening from an invite link, you can check it out on main and it does not function as it should on staging.

We've started a discussion in the issue for this PR with Scott and I'll update you after it gets resolved.

@DylanDylann
Copy link
Contributor

@cdOut Yeah, please ping me when everything is ready. Thanks

src/CONST.ts Outdated Show resolved Hide resolved
src/CONST.ts Outdated Show resolved Hide resolved
src/CONST.ts Outdated Show resolved Hide resolved
src/CONST.ts Show resolved Hide resolved
src/CONST.ts Outdated Show resolved Hide resolved
@@ -7389,6 +7403,40 @@ function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, chatReport: O
);
}

function completePaymentOnboarding(paymentSelected: ValueOf<typeof CONST.PAYMENT_SELECTED>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a JSDoc explaining what the function does

src/libs/actions/IOU.ts Outdated Show resolved Hide resolved
@DylanDylann
Copy link
Contributor

@cdOut I still get some problems with the Android build. Could you help to test on Android?

@cdOut
Copy link
Contributor Author

cdOut commented Sep 5, 2024

I can take a look, native android or mWeb?

@DylanDylann
Copy link
Contributor

It is native android

@cdOut
Copy link
Contributor Author

cdOut commented Sep 5, 2024

@DylanDylann It must be something on your end regarding your android studio configuration, I was able to build and run the app natively as you can see below.

ANDROID.low.res.mov

@DylanDylann
Copy link
Contributor

I built successfully. Also work for me on Android

Screen.Recording.2024-09-05.at.17.19.19.mov

@DylanDylann
Copy link
Contributor

@deetergp All yours

@Expensify Expensify deleted a comment from DylanDylann Sep 5, 2024
@deetergp
Copy link
Contributor

deetergp commented Sep 5, 2024

I've been trying to test this today, but it seems the invoice invite flow is broken again. I'm trying to figure it out and fix it…

@DylanDylann
Copy link
Contributor

Opss, So weird. I can't send invoice now

Screenshot 2024-09-06 at 15 01 35

deetergp
deetergp previously approved these changes Sep 6, 2024
@deetergp
Copy link
Contributor

deetergp commented Sep 6, 2024

It's unfortunate that we can't test invoice invites right now, but this PR isn't the culprit. The changes look good, so I'm going to approve & merge. Thanks for the hard work @cdOut! 👍

@deetergp
Copy link
Contributor

deetergp commented Sep 6, 2024

Damn, you've got a merge conflict, @cdOut. Looks pretty easily resolved.

@cdOut
Copy link
Contributor Author

cdOut commented Sep 6, 2024

@deetergp merge conflicts resolved, PRs all yours 👍

@deetergp deetergp merged commit 1ec3088 into Expensify:main Sep 6, 2024
16 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Sep 6, 2024

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@IuliiaHerets
Copy link

This PR is failing for Web because of issue #48916

@luacmartins
Copy link
Contributor

@cdOut @blazejkustra @deetergp @DylanDylann We're seeing this crash on Firebase. Could you please take a look?

Non-fatal Exception: C7.w: Cannot read property 'message' of undefined
       at .completeOnboarding(address at index.android.bundle:1:3520823)
       at .completePaymentOnboarding(address at index.android.bundle:1:2971836)
       at .payMoneyRequest(address at index.android.bundle:1:2972014)
       at .confirmPayment(address at index.android.bundle:1:5670829)
       at .selectPaymentType(address at index.android.bundle:1:5411983)
       at .onPress(address at index.android.bundle:1:5412471)
       at .onPress(address at index.android.bundle:1:5352874)
       at .onPress(address at index.android.bundle:1:4208137)
       at .t23(address at index.android.bundle:1:4181455)
       at .apply((native):0:0)
       at .anonymous(address at index.android.bundle:1:4182607)
       at ._performTransitionSideEffects(address at index.android.bundle:1:789413)
       at ._receiveSignal(address at index.android.bundle:1:789001)
       at .onResponderRelease(address at index.android.bundle:1:787830)
       at .executeDispatch(address at index.android.bundle:1:1248058)
       at .executeDispatchesAndReleaseTopLevel(address at index.android.bundle:1:1253344)
       at .forEach((native):0:0)
       at .forEachAccumulated(address at index.android.bundle:1:1249574)
       at .anonymous(address at index.android.bundle:1:1253782)
       at .batchedUpdatesImpl(address at index.android.bundle:1:1314722)
       at .batchedUpdates$1(address at index.android.bundle:1:1253268)
       at .dispatchEvent(address at index.android.bundle:1:1253547)
        

@cdOut
Copy link
Contributor Author

cdOut commented Sep 11, 2024

@luacmartins is there any context on when this happened? What steps did you take for this warning to arise?

@cdOut
Copy link
Contributor Author

cdOut commented Sep 11, 2024

Alright so I haven't been able to reproduce the issue yet, but there's two points where something can go wrong to make this error happen.

After opening the app through the invite link we should be sent an object into Onyx from backend for NVP_INTRO_SELECTED, inside which we'll have a choice property. That would be the first point of failure, maybe we don't receive the value here so it's undefined and breaks the flow.

Next up we use the completeOnboarding function while passing CONST.ONBOARDING_MESSAGES[onboardingPurpose] to it, which should be an object containing a message property. Here's another point of failure, as the onboardingPurpose, which is equal to choice, could contain a typo or not be linked with the messages data we store in CONST.

I'll try to see whether I can replicate this issue locally for myself, could you also please provide some more details if there are any, such as if this is happening just for newDot or is this on the hybridApp, or anything else that could be helpful here?

@cdOut
Copy link
Contributor Author

cdOut commented Sep 11, 2024

cc @luacmartins @deetergp

After looking at all the possibilities I think we didn't properly consider the difference between what Onyx data there is for old and new accounts. The problem is in this check in completePaymentOnboarding:

const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false;

if (isInviteOnboardingComplete || !introSelected?.choice) {
    return;
}

This logic works perfectly for how we handle new accounts, but when I went back to one of my old accounts it turns out we sometimes have a value for introSelected.choice, and the command triggers for old accounts that shouldn't have that happen to them and then also receives faulty data.

Screen.Recording.2024-09-11.at.13.09.00.mov

First of all this flow shouldn't trigger here at all, but on top of that we receive and possibly send over faulty data which possibly triggered this error.

We need to add an additional check in the code block above to check whether the value received in NVP_ONBOARDING is an empty array, which means the account has old data made before the Guided Setup additions and shouldn't trigger the flow. By my knowledge of how the backend handles these values. a simple additional check in the code block above for Array.isArray(onboarding), where onboarding is read from NVP_ONBOARDING, should be good enough, but I'd need @deetergp to confirm it.

@luacmartins
Copy link
Contributor

@luacmartins is there any context on when this happened? What steps did you take for this warning to arise?

No, sorry. All I got are those logs.

@deetergp
Copy link
Contributor

@cdOut On the back end, we set an onboarding NVP for organic signups—that is users that come to NewDot or OldDot and create an account for themselves. That NVP from the backend is what becomes NVP_ONBOARDING in Onyx. In the case of users that are invited to NewDot, we do not set anything at all for that NVP on the backend, it simply does not exist for invited users.

@cdOut
Copy link
Contributor Author

cdOut commented Sep 11, 2024

@deetergp so what would you suggest we should check for to only ever trigger the non-organic payment onboarding for email invites and not old accounts that sometimes pass this check?

const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false;

if (isInviteOnboardingComplete || !introSelected?.choice) {
    return;
}

My old accounts had the choice value set for some reason even though they were created way before the onboarding was implemented so they went through this if and trigger the flow on every payment.

@deetergp
Copy link
Contributor

@cdOut Were those accounts invited or did you create them in OldDot or NewDot?

@cdOut
Copy link
Contributor Author

cdOut commented Sep 11, 2024

The one I tested on was created in NewDot around a year ago.

And it does have an empty array set for NVP_ONBOARDING as suggested in the ONYXKEYS type definition here:
Screenshot 2024-09-11 at 18 56 05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants