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

[HOLD for payment 2025-01-02] Remove isArray checks for onboarding #53476

Closed
carlosmiceli opened this issue Dec 3, 2024 · 33 comments
Closed
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@carlosmiceli
Copy link
Contributor

carlosmiceli commented Dec 3, 2024

We have a few isArray checks for displaying or not the onboarding flow. For example:

    // Onboarding is an array or an empty object for old accounts and accounts created from OldDot
    if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {
        return true;
    }

We should clean this up since onboarding has changed and should never be an array. Please include videos of all the flows where we are making this change and showing that it's still working properly afterwards.

Issue OwnerCurrent Issue Owner: @CortneyOfstad
@carlosmiceli carlosmiceli added External Added to denote the issue can be worked on by a contributor Daily KSv2 labels Dec 3, 2024
@carlosmiceli carlosmiceli self-assigned this Dec 3, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 3, 2024
Copy link

melvin-bot bot commented Dec 3, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (External)

@nkdengineer
Copy link
Contributor

nkdengineer commented Dec 3, 2024

Edited by proposal-police: This proposal was edited at 2024-12-03 16:11:19 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Remove isArray checks for onboarding

What is the root cause of that problem?

We're checking isArray here

if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {

if (Array.isArray(onboarding) || isEmptyObject(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) {

if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {

if (onboarding && !Array.isArray(onboarding) && !isEmptyObject(onboarding) && onboarding.chatReportID) {

What changes do you think we should make in order to solve the problem?

Remove isArray check in these places.

if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {

if (Array.isArray(onboarding) || isEmptyObject(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) {

if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {

if (onboarding && !Array.isArray(onboarding) && !isEmptyObject(onboarding) && onboarding.chatReportID) {

We should also update the OnboardingData type to remove the array type

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

@saifelance
Copy link

Problem:

isArray checks for the onboarding flow are outdated. Onboarding should no longer be an array, but the code still checks for it.

Root Cause:

The onboarding data structure has changed, but the code still checks for an array, causing redundancy and potential issues.

Proposed Changes:

Remove Array.isArray checks for onboarding.
Update conditions to reflect the new structure:

if (isEmptyObject(onboarding)) {
    return true;
}

Ensure all references to onboarding match its new structure.

Test Scenarios:

Verify onboarding flow works for old and new accounts.
Ensure no UI issues or broken functionality.
Check onboarding for OldDot accounts.

Alternative Solutions:

Removing these checks is the best solution, no alternatives needed.

@carlosmiceli
Copy link
Contributor Author

FYI, when I just remove the check, I see this warning: Property 'hasCompletedGuidedSetupFlow' does not exist on type 'Onboarding | []'. Property 'hasCompletedGuidedSetupFlow' does not exist on type '[]'.

@getusha Something to consider when looking at proposals.

@nkdengineer
Copy link
Contributor

@carlosmiceli We also need to update OnboardingData type to remove the array type.

@saifelance
Copy link

Update the type of onboarding

let onboarding: Onboarding | [];

to

let onboarding: Onboarding; // Assuming Onboarding is the correct type now

Type assertion (if needed): If you can't change the type definition directly

if (isEmptyObject(onboarding)) {
    return true;
}

const onboardingData = onboarding as Onboarding; // Type assertion
if (onboardingData.hasCompletedGuidedSetupFlow) {
    // Use hasCompletedGuidedSetupFlow safely here
}

Refactor conditional logic:

After removing the Array.isArray check, ensure your checks and conditions align with the new data structure.

@twilight2294
Copy link
Contributor

twilight2294 commented Dec 3, 2024

Edited by proposal-police: This proposal was edited at 2024-12-03 17:50:10 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Remove isArray checks for onboarding

What is the root cause of that problem?

We are no longer sending arrays as Onboarding value, so we are removing them

What changes do you think we should make in order to solve the problem?

We need to do three things, 1 is to remove the usage of isArray check and then 2 is to remove the unit test associated with it as well and 3 is to clear the array type from multiple places
Remove the usage of Array.isArray(onboarding) from the following paces:

if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {

if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {

if (Array.isArray(onboarding) || isEmptyObject(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) {

if (onboarding && !Array.isArray(onboarding) && !isEmptyObject(onboarding) && onboarding.chatReportID) {

Also we need to remove the | [] type assumption from below:

type OnboardingData = Onboarding | [] | undefined;

Also need to clear the [] array type from below (Note that it is important to also remove the array assumption from below and not only OnboardingData:

App/src/ONYXKEYS.ts

Lines 875 to 876 in b255293

// NVP_ONBOARDING is an array for old users.
[ONYXKEYS.NVP_ONBOARDING]: Onboarding | [];

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

Instead of covering a extra test, we should remove an existing unit test which covers the array case:

it('Should return true if onboarding NVP is an array', () => {
const onboarding = [] as OnyxValue<typeof ONYXKEYS.NVP_ONBOARDING>;
expect(hasCompletedGuidedSetupFlowSelector(onboarding)).toBe(true);
});

(This is also important)

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Dec 3, 2024
@nkdengineer
Copy link
Contributor

Just a note here: it's easy to remove the existing unit test while implementing the PR because the typecheck will fail after we remove array type from OnboardingData.

@twilight2294
Copy link
Contributor

I would also like to note that proposals are meant to cover these cases that is why we have the new section in proposal template, it takes time to research and write a complete and correct proposal

Copy link

melvin-bot bot commented Dec 11, 2024

@carlosmiceli, @getusha Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@carlosmiceli carlosmiceli assigned allgandalf and unassigned getusha Dec 11, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 11, 2024
@carlosmiceli
Copy link
Contributor Author

Removing @getusha since there's been no response. Asking in Slack for a new C+.

@carlosmiceli carlosmiceli assigned dominictb and unassigned allgandalf Dec 11, 2024
@dominictb
Copy link
Contributor

Reviewing.

@dominictb
Copy link
Contributor

Thanks all for your proposals.

There are 2 minor improvements suggested by @twilight2294 that has not been covered by @nkdengineer. But I agree with @nkdengineer reasoning here #53476 (comment) that these are straight forward and can be easily discovered during implementation.

Let's go with @nkdengineer proposal #53476 (comment)
🎀👀🎀

Copy link

melvin-bot bot commented Dec 13, 2024

Current assignee @carlosmiceli is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@carlosmiceli carlosmiceli removed the Improvement Item broken or needs improvement. label Dec 18, 2024
@nkdengineer
Copy link
Contributor

This should be split between @nkdengineer (main proposal) and @twilight2294 (improvement on top of the proposal).

@carlosmiceli Thanks, I agree. I can take the PR phrase.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Dec 20, 2024
@CortneyOfstad
Copy link
Contributor

@carlosmiceli — I'm a bit confused by the comment here. Are you referencing splitting the payment?

@CortneyOfstad
Copy link
Contributor

Also, just a heads up — I will be OOO starting this afternoon (December 20th) and will be returning January 6th. A handful of folks on the BZ team will be online for a few days in between the 25th and the 1st, but we'll be operating with a skeleton crew. If there is any action needed from a BZ perspective, please post this issue in #expensify-open-source and someone on the team will jump in. Otherwise, I will review when I return on January 6th. Thanks and Happy Holidays!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 26, 2024
@melvin-bot melvin-bot bot changed the title Remove isArray checks for onboarding [HOLD for payment 2025-01-02] Remove isArray checks for onboarding Dec 26, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 26, 2024
Copy link

melvin-bot bot commented Dec 26, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Dec 26, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.78-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-01-02. 🎊

For reference, here are some details about the assignees on this issue:

  • @nkdengineer requires payment (Needs manual offer from BZ)
  • @dominictb requires payment (Needs manual offer from BZ)
  • @twilight2294 requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Dec 26, 2024

@dominictb @CortneyOfstad @dominictb The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 2, 2025
Copy link

melvin-bot bot commented Jan 2, 2025

Payment Summary

Upwork Job

BugZero Checklist (@CortneyOfstad)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Jan 6, 2025
Copy link

melvin-bot bot commented Jan 7, 2025

@carlosmiceli, @CortneyOfstad, @nkdengineer, @dominictb, @twilight2294 Huh... This is 4 days overdue. Who can take care of this?

@CortneyOfstad
Copy link
Contributor

So the automation for the job post did not go through, so had to manually create and invite.

Job Post

https://www.upwork.com/jobs/~021876673210696870740

@melvin-bot melvin-bot bot removed the Overdue label Jan 7, 2025
@CortneyOfstad
Copy link
Contributor

@nkdengineer, @dominictb, @twilight2294 — I've sent you all offers, please let me know once you accept and I can get those paid ASAP.

@dominictb
Copy link
Contributor

@CortneyOfstad Offer accepted, thanks for handling this 🙇

@melvin-bot melvin-bot bot added the Overdue label Jan 10, 2025
@CortneyOfstad
Copy link
Contributor

Payment Summary

@twilight2294 — paid $125 via Upwork
@nkdengineer — paid $125 via Upwork
@dominictb — paid $250 via Upwork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants