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

Create v1 Collect workspace Bottom Up flow #30582

Merged
merged 33 commits into from
Nov 22, 2023
Merged

Create v1 Collect workspace Bottom Up flow #30582

merged 33 commits into from
Nov 22, 2023

Conversation

mountiny
Copy link
Contributor

@mountiny mountiny commented Oct 30, 2023

Details

In this PR we are implementing a basic v1 bottom up flow in which users can:

  • choose to pay p2p IOU report with business bank account
  • collect workspace is created for them as admin and the submitter as employee
  • the IOU report is converted to an expense report, the parent report changes to the new workspace chat, change the report to tal to negative amount as its done in case of expense reports
  • the transaction data is updated to match expected transaction data for a workspace (amount is changed to negative value)
  • We are adding a new Moved report action which is used to link the DM with the new workspace chat

Fixed Issues

$ #30702

Tests

For testing purposes as Expensify Engineer locally set the skipGuidesAssignent to true on this line as most likely the guide assignment might not be working well for you locally and it could cause the call to fail.

  1. Set your location/ VPN to the USA (thats to ensure the policy currency is set to USD which is the only currency we support for the business bank accounts in NewDot right now)
  2. Create 2 accounts, one will be used as employee and second as an admin (now they are just a normal pals, friends, nothing more than that, but we will change them to an admin and employee in this flow)
  3. Request 1:1 money as employee from the admin (the IOU report can only have "one-way" requests, if the admin would also request some money from the employee, this flow is not allowed/accessible)
  4. As admin, go to the 1:1 chat and click Pay With Expensify
  5. Choose to pay with Business Bank account
  6. Verify you have been brought to the Bank account flow
  7. Close the bank account flow
  8. Verify you can see a new report message in the 1:1 chat which links you to the workspace chat of the new employee
  9. Click on the link (when developing in localhost against staging api, the link will point to staging so you will have to update it)
  10. Verify you can see a report preview for the same amount request in the expense report
  11. Verify you can navigate to the expense report both as admin and employee
  12. Verify the expense report and workspace chat correctly show the default workspace avatar in the LHN
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

QA Steps

Same as tests

  • 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 approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • 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 a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
      • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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(themeColors.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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@mountiny mountiny self-assigned this Oct 30, 2023
@mountiny mountiny changed the title Collect Bottom UP flow Collect Bottom Up flow Oct 30, 2023
src/CONST.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@puneetlath puneetlath left a comment

Choose a reason for hiding this comment

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

Looking good! Just some minor feedback.

src/libs/ReportActionsUtils.ts Outdated Show resolved Hide resolved
src/libs/actions/Policy.js Outdated Show resolved Hide resolved
src/libs/actions/Policy.js Outdated Show resolved Hide resolved
@Julesssss
Copy link
Contributor

Julesssss commented Nov 22, 2023

fwiw the logs suggest you did not change

I 100% did this. I was very careful to save the file given that this was the 3rd test. Maybe there is another line that I need to comment out?

@akinwale
Copy link
Contributor

@mountiny Test results with staging server enabled. Video showing fresh accounts (left: admin, right: employee) included.

Requesting (employee) user

  • Added to #announce room for the created workspace
  • Collab. IOU report created (collaboration between user and workspace)
  • No workspace chat

Requestee (admin) user

  • Added to #admin and #announce rooms for the workspace
  • Collab. IOU report created
  • IOU report moved
  • No workspace chat
30582-web-3.mp4

@puneetlath
Copy link
Contributor

I see the employee's workspace chat there for both. Isn't it these? Seems like it's working correctly to me.

Screenshot 2023-11-22 at 2 59 35 PM

@puneetlath
Copy link
Contributor

Oh, I guess the admin's own workspace chat doesn't seem to have been added. But the employee's does for both.

@akinwale
Copy link
Contributor

Oh, I guess the admin's own workspace chat doesn't seem to have been added. But the employee's does for both.

Yeah, I assumed we're looking for the workspace's chat room which is different from those. I opened all the reports in the video just to make sure.

@mountiny
Copy link
Contributor Author

It was added optimistically but then disappeared, I think this might be something to do with the Collect policy settings. This would require a change in the backend I have created a follow up to investigate so we do not forget about this #31754

Both users have workspace chat and seems like everything worked so I am going to go ahead with merge. Thanks everyone fore testing and reviewing 🚀

@mountiny mountiny merged commit 6aa94c9 into main Nov 22, 2023
21 checks passed
@mountiny mountiny deleted the vit-bottomUp branch November 22, 2023 21:21
@OSBotify
Copy link
Contributor

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.3-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 cancelled 🔪
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.3-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@situchan situchan mentioned this pull request Nov 23, 2023
47 tasks
{
text: translate('common.businessBankAccount'),
icon: Expensicons.Building,
onSelected: () => onItemSelected(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT),
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused crash - #31797 as it fallback to throw here:

throw new Error('Invalid payment method type selected');

Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID));
return;
}
Navigation.navigate(this.props.addBankAccountRoute);
Copy link
Contributor

@luacmartins luacmartins Nov 23, 2023

Choose a reason for hiding this comment

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

I think this default might be incorrect. I think this defaults to a personal bank account since we pass it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be correct because we pass it to the SettlementButton in both cases using this method which checks if the parent report is workspace chat or DM

const bankAccountRoute = ReportUtils.getBankAccountRoute(chatReport);

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 1.4.3-11 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

if (isExpenseReport) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
}
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
Copy link
Contributor

Choose a reason for hiding this comment

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

},
},
...(Permissions.canUseWallet(props.betas)
...(ReportUtils.isIOUReport(iouReport)
Copy link
Contributor

Choose a reason for hiding this comment

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

Send money case was missing in this condition, which caused #32228

onSelected: () => {
props.onItemSelected(CONST.PAYMENT_METHODS.BANK_ACCOUNT);
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This also removed personal bank account option in Wallet page. Issue: #32079


const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Coming from #31836.
As there isn't a better way at the moment to update data immediately before navigation, we have fallen back to using the SET method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

😢 This is multiple times I've seen this used and I think it is a hack and that we should really try to find some other real solution to the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did raise that concern in the linked issue, however, no other viable solution has been found in couple of weeks. Then given we already use the SET for classic policy creation (so not part of the bottom up flow), I agree to proceed with using SET.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you be OK with creating a GH issue with a solid problem statement and start getting some proposals for fixing it? I'd like to not just let this one fade away with others continuing to copy the same hack. I have some ideas like:

  • If there was just a merge() then the data should be immediately (and synchronously) available in the Onyx cache. Let's find a way to use it faster
  • Is the problem because subscribers aren't notified until the next-tick? If so, maybe we can add an option to Onyx to bypass for some scenarios (since it was only added as an optimization)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have this saved, but I still did not get around to do this focusing on Ideal nav and waves in general. Noting previous comment from another PR for future.

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.

10 participants