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

[feature]: Using the product as a copilot #48594

Merged
merged 52 commits into from
Sep 26, 2024

Conversation

allgandalf
Copy link
Contributor

@allgandalf allgandalf commented Sep 4, 2024

Details

Add delegate avatar and delegate message

Fixed Issues

$ #46926
PROPOSAL: https://expensify.slack.com/archives/C02NK2DQWUX/p1725046112539189?thread_ts=1725040927.420699&cid=C02NK2DQWUX

Tests

  • Precondition: delegate should have full access to the delegator account
  1. Login to delegate account.
  2. Switch to delegator account.
  3. Performs action like:
  • Commenting
  • Creating a Task, updating task, completing, assigning task
  • Submitting an expense (Not creating but submitting ****)
  • Approving an expense
  • Paying an expense
  • Verify that, all these actions have header on behalf of:
    image
  • Verify that no errors appear in the JS console

Offline tests

  • Precondition: delegate should have full access to the delegator account
  1. Login to delegate account.
  2. Switch to delegator account.
  3. Performs action like:
  • Commenting
  • Creating a Task, updating task, completing, assigning task
  • Submitting an expense (Not creating but submitting ****)
  • Approving an expense
  • Paying an expense
  • Verify that, all these actions have header on behalf of:
    image

QA Steps

  • Precondition: delegate should have full access to the delegator account
  1. Login to delegate account.
  2. Switch to delegator account.
  3. Performs action like:
  • Commenting
  • Creating a Task, updating task, completing, assigning task
  • Submitting an expense (Not creating but submitting ****)
  • Approving an expense
  • Paying an expense
  • Verify that, all these actions have header on behalf of:
    image
  • 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari Screenshot 2024-09-06 at 1 18 26 PM
MacOS: Desktop

@allgandalf allgandalf changed the title Issue46926 p2 [feature]: Using the product as a copilot Sep 4, 2024
@allgandalf
Copy link
Contributor Author

I will open the PR up for review today

@allgandalf allgandalf marked this pull request as ready for review September 6, 2024 07:43
@allgandalf allgandalf requested review from a team as code owners September 6, 2024 07:43
@melvin-bot melvin-bot bot requested review from rushatgabhane and removed request for a team September 6, 2024 07:43
Copy link

melvin-bot bot commented Sep 6, 2024

@rushatgabhane 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]

Co-authored-by: Daniel Gale-Rosen <5487802+dangrous@users.noreply.github.com>
@allgandalf
Copy link
Contributor Author

t @allgandalf I don't think anything needs to change on the front end for that, right?

With the latest slack convo, I guess we are not allowing that functionality for a delegate, so should we block sending invoices for delegates @dangrous ?

@allgandalf
Copy link
Contributor Author

Yep I'll double check but as long as any major issues are contained within the beta we should be fine to not revert. We should keep watch though once we merge to make sure we can fix anything that happens to be outside of the beta quickly!

Yeah, I am confident this will not break break any major functionality, because the delegateAccountID will by default be empty if we are not logged in as a delegate so no major bugs for normal users

Also, I will not have access to my mac for atleast 1 day for either later this week or early next week (Submitting mac for a screen replacement and they want the mac as soon as screen arrives ) so i hope this gets into staging today or atleast delay the deployment until next week. c.c. @rushatgabhane @DylanDylann just in case i might not be help during that time.

@dangrous
Copy link
Contributor

Backend is deployed, can we do another quick round of tests to make sure everything's matching? Just spot check the tasks, changelogs, that weren't there before.

Then I think we should be good to merge

and @allgandalf sounds like your 1 day w/out computer is today, which I think will work well if we merge later today, will be on staging tomorrow probably.

As for invoices, I think we can handle that in a follow up since we need the details and it came late. If you're okay with handling once we have those details?

@dangrous
Copy link
Contributor

dangrous commented Sep 25, 2024

Posting a couple bugs as I find them:

  • I haven't figured out exact steps but creating an account, adding a copilot, immediately logging in as that copilot and switching accounts, then take an action, seems to know it's a copilot action but not showing the correct name. I checked Onyx and the delegateAccountID is there and correct (all of these comments were sent from copilots, the bottom one is a fresh copilot I just added):
    Screenshot 2024-09-25 at 11 44 28
  • In pretty much all cases I'm seeing a blank line where the original account should be when trying to switch back from a copiloted account.
    Screenshot 2024-09-25 at 11 44 44

Let me know if you think either/both of these is backend but I don't think they are? The second might be the personal details thing we're working through separately.

@allgandalf
Copy link
Contributor Author

allgandalf commented Sep 26, 2024

can we do another quick round of tests to make sure everything's matching?

For sure, @DylanDylann can you also help me with this, I will respond to other comments in sometime, just got back

@allgandalf allgandalf closed this Sep 26, 2024
@allgandalf allgandalf reopened this Sep 26, 2024
@allgandalf
Copy link
Contributor Author

Oops, sorry my bad 😓

@allgandalf
Copy link
Contributor Author

I Tested and Verified the following Work:

  • Submitting an expense
  • Approving an expense
  • Paying Expense (NOTE: Only tested with pay elsewhere as i do not have a US account, but should work fine, I believe)
  • Holding/Unholding Expense
  • Sending an attachment
  • Creating/Deleting task
  • Completing/Commenting on/Assigning tasks
  • Chatting (In workspace/DM/threads)
  • Editing workspace settings (Admins room)

@allgandalf
Copy link
Contributor Author

As for invoices, I think we can handle that in a follow up since we need the details and it came late. If you're okay with handling once we have those details?

Sure thing, lets follow up when we have more info

@allgandalf
Copy link
Contributor Author

I haven't figured out exact steps but creating an account, adding a copilot, immediately logging in as that copilot and switching accounts, then take an action, seems to know it's a copilot action but not showing the correct name. I checked Onyx and the delegateAccountID is there and correct (all of these comments were sent from copilots, the bottom one is a fresh copilot I just added):

TBH i am really clueless how these system messages really work, I spend half day last week finding code for the messages and found out they come from BE, What i propose is, lets ship this PR and follow up on this issue on slack if it occurs (The system messages worked fine for me during testing now).

@allgandalf
Copy link
Contributor Author

In pretty much all cases I'm seeing a blank line where the original account should be when trying to switch back from a copiloted account.

Can you share reproducible steps?

I am having a difficulty reproducing that

@allgandalf
Copy link
Contributor Author

Soo, With that I feel, lets merge this one and hope the QA doesn't find any major flaws 🤞

@dangrous
Copy link
Contributor

I haven't figured out exact steps but creating an account, adding a copilot, immediately logging in as that copilot and switching accounts, then take an action, seems to know it's a copilot action but not showing the correct name. I checked Onyx and the delegateAccountID is there and correct (all of these comments were sent from copilots, the bottom one is a fresh copilot I just added):

TBH i am really clueless how these system messages really work, I spend half day last week finding code for the messages and found out they come from BE, What i propose is, lets ship this PR and follow up on this issue on slack if it occurs (The system messages worked fine for me during testing now).

For this one it was happening for chats for me as well:

image

That's from an account copiloted in - so the display name and icon should be the copilot account, but it's the account that is being copiloted into...

I'm also just seeing the blank line on the basic flow of adding a copilot, logging in as the copilot, and switching into the copiloted account.

However, I just tried on the staging server and it looks like these are okay there so it must be something with my local. Hopefully it's fine, though I'm not sure what the difference would be.

Copy link
Contributor

@dangrous dangrous left a comment

Choose a reason for hiding this comment

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

let's do it!

@dangrous dangrous merged commit 4f93277 into Expensify:main Sep 26, 2024
18 checks passed
@dangrous
Copy link
Contributor

@allgandalf can you take a look at this typeerror:

Type '{ common: { cancel: string; dismiss: string; yes: string; no: string; ok: string; notNow: string; learnMore: string; buttonConfirm: string; name: string; attachment: string; attachments: string; center: string; ... 224 more ...; rename: string; }; ... 173 more ...; debug: { ...; }; }' does not satisfy the expected type 'TranslationDeepObject<{ common: { cancel: string; dismiss: string; yes: string; no: string; ok: string; notNow: string; learnMore: string; buttonConfirm: string; name: string; attachment: string; attachments: string; center: string; ... 224 more ...; rename: string; }; ... 173 more ...; debug: { ...; }; }>'. The types of 'delegate.onBehalfOfMessage' are incompatible between these types. Type '(delegator: string) => string' is not assignable to type '(arg: Record<string, unknown>, ...noOtherArguments: unknown[]) => string | PluralForm'. Types of parameters 'delegator' and 'arg' are incompatible. Type 'Record<string, unknown>' is not assignable to type 'string'.

@dangrous
Copy link
Contributor

actually I think I have it, i can put up a PR in a sec

@dangrous
Copy link
Contributor

#49821 if @DylanDylann or @allgandalf you want to take a look

Copy link
Contributor

🚀 Deployed to staging by https://github.com/dangrous in version: 9.0.41-0 🚀

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

This comment has been minimized.

Copy link
Contributor

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.

5 participants