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

[OldDot Rules Migration] Tag rules #48325

Merged
merged 36 commits into from
Sep 19, 2024

Conversation

BrtqKr
Copy link
Contributor

@BrtqKr BrtqKr commented Aug 30, 2024

Holding on:

Details

Fixed Issues

$ #47016
$ #48977
PROPOSAL:

Tests

  1. Go to Profile => workspaces => select a workspace => tags
  2. Select an existing tag, or create a new one
  3. Change approver
  4. Verify that selecting the same person, removes them as an approver
  5. Verify that there are correct system messages being sent to the admin channel

Verify that disabling rules in more features, disables approver as well

image
  • 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

Android: Native
Screen.Recording.2024-09-05.at.12.26.16.mov
Android: mWeb Chrome
Screen.Recording.2024-09-05.at.12.31.59.mov
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-09-05.at.11.58.45.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-09-05.at.12.05.07.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-09-05.at.10.41.15.mov
MacOS: Desktop
Screen.Recording.2024-09-05.at.12.36.56.mov

Copy link

melvin-bot bot commented Aug 30, 2024

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

@marcaaron marcaaron changed the title [OldDot Rules Migration] Tag rules [HOLD] [OldDot Rules Migration] Tag rules Sep 5, 2024
@marcaaron marcaaron changed the title [HOLD] [OldDot Rules Migration] Tag rules [OldDot Rules Migration] Tag rules Sep 6, 2024
@marcaaron
Copy link
Contributor

The PRs we were waiting on are now deployed or merged so we can take this off HOLD.

@BrtqKr
Copy link
Contributor Author

BrtqKr commented Sep 9, 2024

@marcaaron, it seems to be in a different field than I initially expected, but I've applied the changes and it's working. I believe we can pass it on for review.

@BrtqKr BrtqKr marked this pull request as ready for review September 9, 2024 09:27
@BrtqKr BrtqKr requested a review from a team as a code owner September 9, 2024 09:27
@melvin-bot melvin-bot bot requested a review from rojiphil September 9, 2024 09:27
Copy link

melvin-bot bot commented Sep 9, 2024

@rojiphil 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 removed the request for review from a team September 9, 2024 09:27
@rojiphil
Copy link
Contributor

@BrtqKr I will review the PR today. Meanwhile, can you please resolve the conflicts? Thanks

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

@BrtqKr I have a few observations as mentioned below but the overall code looks super good though:

  1. Once an approver is selected, we do not allow deselecting the approver to set it to none. I think we need to support this considering that OldDot supports this.
  2. The test steps in PR mentions this:

Verify that disabling tags in more features, disables approver as well

Neither do I see any implementation for this nor do I see any reference to this in test videos. Have we missed implementing this? Also, what would disables approver mean here? I think it will help QA if we can further break down the test steps

@BrtqKr
Copy link
Contributor Author

BrtqKr commented Sep 10, 2024

@rojiphil

  1. I've added the removal option
  2. That's an error in the description, I meant rules and that's already implemented
                    {policy?.areRulesEnabled && (
                        <>
                            <View style={[styles.mh5, styles.mv3, styles.pt3, styles.borderTop]}>
                                <Text style={[styles.textNormal, styles.textStrong, styles.mv3]}>{translate('workspace.tags.tagRules')}</Text>
                            </View>
                            <OfflineWithFeedback pendingAction={policy.pendingFields?.rules}>
                                <MenuItemWithTopDescription
                                    title={tagApprover ?? ''}
                                    description={translate(`workspace.tags.approverDescription`)}
                                    onPress={navigateToEditTagApprover}
                                    shouldShowRightIcon
                                />
                            </OfflineWithFeedback>
                        </>
                    )}

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

2. That's an error in the description, I meant rules and that's already implemented

@BrtqKr Thanks for the changes. The removal feature works fine but the feature of disabling approvers does not seem to be implemented yet as we do for category approver rules. Here is a test video demonstrating this. Please have a look. Thanks

48325-disabledapprover.mp4

@marcaaron marcaaron self-requested a review September 10, 2024 20:31
@BrtqKr
Copy link
Contributor Author

BrtqKr commented Sep 10, 2024

if I understand correctly the condition should probably be uniform and it's been missing for the categories. It's already applied with the remaining fixes

@BrtqKr
Copy link
Contributor Author

BrtqKr commented Sep 18, 2024

I've removed the offline pattern and added category/tag renaming in the rules. I believe this would be everything

Screen.Recording.2024-09-18.at.01.57.14.mov

@@ -2578,7 +2578,10 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
});

// We need to move the report preview action from the DM to the workspace chat.
const reportPreview = ReportActionsUtils.getParentReportAction(iouReport);
const parentReport = ReportAcionsConnection.getAllReportActions()?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport.parentReportID}`];
Copy link
Contributor

Choose a reason for hiding this comment

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

@BrtqKr Not sure if I am missing something here but why did we have to create ReportAcionsConnection when we already have a utility ReportActionsUtils.getAllReportActions?

Copy link
Contributor Author

@BrtqKr BrtqKr Sep 18, 2024

Choose a reason for hiding this comment

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

because we have a new eslint rule, which is forcing us to fix those things when we edit files containing deprecated code

well, not exactly eslint rule, but more like a check included inside of the one for eslint

Copy link
Contributor

@rojiphil rojiphil Sep 18, 2024

Choose a reason for hiding this comment

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

@BrtqKr Ah! I see. So, the deprecated function is getParentReportAction but is there a need to create ReportAcionsConnection.getAllReportActions() when ReportActionsUtils.getAllReportActions gives us the same result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is something I'll need to discuss separately, but from what I understand the main issue is that the rule has been prepared with components in mind, so it's expecting some kind of action to be taken anyway. I was thinking about the possible benefits of having a connection in one place instead of having logic split between different files, but as I said earlier, I'll discuss it in more detail with someone who has more context.

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't feel like a blocker.

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 something I'll need to discuss separately

getParentReportAction has been used in many places and I agree that this needs a separate discussion. Since this is not at all related to this issue, I would prefer not to include the changes for this in this PR. As and when there is a conclusion on the way forward, we can add the code changes. Anyway, I would leave the final decision on this to @marcaaron.

If we are leaving the code as it is, let us correct the spelling ReportAcionsConnection.

@@ -27979,22 +27979,6 @@
"jest": "bin/jest.js"
}
},
"node_modules/jest-expo/node_modules/@babel/code-frame": {
Copy link
Contributor

Choose a reason for hiding this comment

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

@BrtqKr Did this change got introduced unintended as these seem unrelated to our current scope 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 haven't modified anything in package.json and I'm using the appropriate node version. The change was introduced right after merging main to this branch and reinstalling the packages, so I'd assume it wasn't indended, but it's correct.

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 doesn't seem like a blocker.

@rojiphil
Copy link
Contributor

Otherwise the code looks good and the feature works well.
I have left a couple of comments. Once we address them, I can do the final testing.
Looks very close to getting this done.

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

@BrtqKr I have left few suggestions related to test cases

  1. Let us add the below mentioned steps from 5th step onward in the existing test steps.
  • Select an approver again
  • Change the name of the tag
  • Verify that the approver does not change.
  1. Also, let us add the following so that QA can test categories too

Repeat the above mentioned steps for categories and verify.

  1. Let us remove the following text from steps as QA will get confused:

Verify that disabling rules in more features, disables approver as well

@marcaaron Other than this comment, the code changes related to tag/category approver feature LGTM and works well too and I have completed the checklist.
Over to you for review.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -3233,6 +3233,8 @@ export default {
importedFromAccountingSoftware: 'Etiquetas importadas desde',
glCode: 'Código de Libro Mayor',
updateGLCodeFailureMessage: 'Se produjo un error al actualizar el código de Libro Mayor. Por favor, inténtelo nuevamente.',
tagRules: 'Reglas de etiquetas',
approverDescription: 'Aprobador',
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB we could probably move this to the general since it is used twice.

@marcaaron marcaaron merged commit 0045eae into Expensify:main Sep 19, 2024
19 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/marcaaron in version: 9.0.39-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 9.0.39-5 🚀

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

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.

5 participants