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

[CRITICAL] Implement <WorkspaceWorkflowsApprovalsCreatePage /> for Workflow Creation #46798

Conversation

blazejkustra
Copy link
Contributor

@blazejkustra blazejkustra commented Aug 5, 2024

Details

Link to the doc.

UI changes

image

Members:
<MenuItemWithTopDescription /> that displays all currently selected users for a given approval workflow.

image

Approvers:

The whole section is dynamic as there is no limit on how many approvers there are.
Always one empty input is displayed to allow for adding additional approvers.
When there are more than one approver these items will be enumerated, toLocaleOrdinal will generate the ordinal based on the index of an approver.

image

Onyx actions:

Clicking the back button will use the clearApprovalWorkflow action and navigate back to the workflows page (‘settings/workspaces/:policyID/workflows’).

Clicking on the “Add workflow” button will trigger createApprovalWorkflow action and navigate back to the workflows page (‘settings/workspaces/:policyID/workflows’).

Edge cases

In case one of the approvers already has an existing forwardsTo in place, we’ll populate that relationship when creating/editing an approval workflow - this will be implemented in setApprovalWorkflowApprover when selecting an approver. Hint text will be displayed based on isApproverInMultipleWorkflows saved in the Onyx for each Approver. This utilizes hintText prop from <MenuItem /> component.

image

If the same person is chosen twice in one workflow, a dot indicator with an error message will be displayed to the user. This utilizes errorText prop from <MenuItem /> component.

image

Fixed Issues

$ #45954
PROPOSAL: N/A

Tests

  • Open Workflows page (it has to be turned on in More features settings page)
  • Locally edit canUseWorkflowsAdvancedApproval function to return true (or use canUseWorkflowsAdvancedApproval beta)
  • Click on the 'Add approval workflow' button, it should navigate to 'Expenses from' page, select some users
  • Go to the next step, select an approver
  • Next button should navigate to the create new workflow page
  • Play around with this page, you should be able to:
    • Add more approvers,
    • Remove already selected approvers,
    • Change members of the workflow
  • Click on 'Add new workflow', it should show up on the workflow page

Offline tests

N/A

QA Steps

Same as tests

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 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 form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label 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

Android: Native
android.webm
Android: mWeb Chrome
android-web.webm
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-web.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov

@blazejkustra blazejkustra changed the title Test navigation Implement <WorkspaceWorkflowsApprovalsCreatePage /> for Workflow Creation Aug 5, 2024
src/ROUTES.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@adamgrzybowski adamgrzybowski left a comment

Choose a reason for hiding this comment

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

LGTM but please fix lint problems

Copy link

melvin-bot bot commented Aug 7, 2024

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@blazejkustra
Copy link
Contributor Author

@shawnborton Check this out when you have some time, the whole creation flow is ready 😄

@DylanDylann
Copy link
Contributor

DylanDylann commented Aug 13, 2024

@blazejkustra Should we hide the add approval button if the member list is empty?

Screen.Recording.2024-08-13.at.15.13.26.mov

cc @Expensify/design

@blazejkustra
Copy link
Contributor Author

@blazejkustra Should we hide the add approval button if the member list is empty?

Not sure about this, but it's a minor thing we can adjust later. Curious to see design team opinion on this (cc @shawnborton as you have a lot of context)

@melvin-bot melvin-bot bot requested a review from tgolen August 13, 2024 08:51
@dannymcclain
Copy link
Contributor

Should we hide the add approval button if the member list is empty?

🤔 How is the member list empty? Regardless, I think I'd be in favor of leaving the Add approval button there, unless someone else has some good, strong arguments for hiding it.

@DylanDylann
Copy link
Contributor

DylanDylann commented Aug 13, 2024

@dannymcclain If a member belongs to an approval workflow, we will not display this member in the new approval workflow. In this case, all members belong to the previous approval workflows, so there are no members in the member list anymore

@dannymcclain
Copy link
Contributor

Ah thank you for explaining that! Makes perfect sense. @Expensify/design I wonder if in that case we should display an "empty state" when you click the Add approval workflow button?

I don't love the idea of that button just going away without any explanation. I don't know that any users will understand why that's happening. I think it'd be better to somehow tell the user "Hey, all your members are part of approval workflows already! Right on. Everyone is getting approved. Way to go."

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Just a couple of quick renames!

@@ -23,11 +25,29 @@ type FormHelpMessageProps = {

/** Whether to show dot indicator */
shouldShowRedDotIndicator?: boolean;

/** Whether should render error text as HTML or as Text */
shouldParseMessage?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please rename this to shouldRenderErrorAsHTML so it is more explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to shouldRenderMessageAsHTML as this correlates better with other message prop

const theme = useTheme();
const styles = useThemeStyles();

const processedText = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to getHTMLMessage

Copy link
Contributor Author

@blazejkustra blazejkustra Aug 13, 2024

Choose a reason for hiding this comment

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

Renamed to HTMLMessage (as this is not a function but a memo)

@@ -261,6 +261,12 @@ type MenuItemBaseProps = {
/** Whether should render helper text as HTML or as Text */
shouldParseHelperText?: boolean;

/** Whether should render hint text as HTML or as Text */
shouldParseHintText?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename these to shouldRenderHintAsHTML and shouldRenderErrorAsHTML

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are other props in this component that are named similary, are we sure we want to name it differently?

shouldParseTitle = false,
shouldParseHelperText = false,
shouldParseHintText = false,
shouldParseErrorText = false,

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think having them more explicit is better than consistency. In fact, I'd suggest renaming all of them in order to really clean it up.

As an external consumer of the component, I wouldn't really have any idea what "parse text" implies and I'd have to dig into the component and look at the code to try to understand it.

Copy link
Contributor

Choose a reason for hiding this comment

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

but to be clear, I'm not asking you to rename the other props in this PR :D Maybe you or I could do a followup PR to clean those up later.

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'll do it in a separate PR 👍

@tgolen tgolen merged commit c010e8c into Expensify:main Aug 13, 2024
18 checks passed
@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/tgolen in version: 9.0.20-0 🚀

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

@mvtglobally
Copy link

@DylanDylann @tgolen Do we need to use specific account to QA this or its part of BETA and should be enabled for Expensifail accounts?

@blazejkustra
Copy link
Contributor Author

blazejkustra commented Aug 14, 2024

@DylanDylann @tgolen Do we need to use specific account to QA this or its part of BETA and should be enabled for Expensifail accounts?

@mvtglobally Yes, it's behind a flag, specifically workflowsAdvancedApproval beta.

const approverHintMessage = useCallback(
(approver: Approver | undefined, approverIndex: number) => {
const previousApprover = approvalWorkflow.approvers.slice(0, approverIndex).filter(Boolean).at(-1);
if (approver?.isInMultipleWorkflows && approver.email === previousApprover?.forwardsTo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@blazejkustra It fails in this case. We shouldn't display hint text

Uploading Screenshot 2024-08-14 at 15.34.35.png…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a valid point @DylanDylann, I think we should change the hint message to something simpler as the current message is making the display logic impossible (there are too many cases which we can't handle with just one hint message).

@JmillsExpensify what do you think to change the hint message to something more generic?

[email protected] is already used in a separate workflow. If you change this approval relationship, all other workflows will be updated.

@Beamanator
Copy link
Contributor

FYI I believe this was deployed to prod yesterday, from this checklist - #47356

const errorText = approverErrorMessage(approver, approverIndex);
const hintText = !errorText && approverHintMessage(approver, approverIndex);
return (
<MenuItemWithTopDescription
Copy link
Contributor

Choose a reason for hiding this comment

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

As it's allowed to edit approver, this item should be wrapped with OfflineWithFeedback. This causes a regression #50477

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

Successfully merging this pull request may close these issues.