App icon indicating copy to clipboard operation
App copied to clipboard

feat: Expense Tracking in the Workspace Chat

Open paultsimura opened this issue 1 year ago • 16 comments

Details

Fixed Issues

$ https://github.com/Expensify/App/issues/38971 PROPOSAL: N/A

Tests

  • [ ] 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

paultsimura avatar Mar 29 '24 13:03 paultsimura

I've created this draft PR to start tracking the existing issues that are blocking the PR, but are not directly related to it.

paultsimura avatar Mar 29 '24 13:03 paultsimura

First of all, the App is crashing because of the Shortcut feature – it doesn't support the TRACK_* actions. I need to get copies for the Shortcut button for the following actions:

  • trackManual
  • trackScan
  • trackDistance
image

@thienlnam could you please help with adding the corresponding label or tagging relevant people?

paultsimura avatar Mar 29 '24 13:03 paultsimura

Another issue – the removal doesn't work as expected. It removes the action optimistically, but after a refresh, the action reappears as a skeleton, and the transaction thread exists, but with an empty transaction.

@shubham1206agra is it known from the times you implemented the self-dm tracking?

https://github.com/Expensify/App/assets/12595293/45fd7f72-d92e-4a96-8ee2-196afeb95486

paultsimura avatar Mar 29 '24 13:03 paultsimura

Yes it's a known issue @thienlnam is working on this

shubham1206agra avatar Mar 29 '24 13:03 shubham1206agra

A couple more things I'd like to clarify:

image

First – there is no visual difference between the tracking expense (1st) and the actual money request (2nd) – do we want to change it?


Second – I'd like to know more about the expected total separation.

  1. Do I understand correctly that adding a Tracking Expense inside an Expense Report should increase the Total and Company spend, but not the Out-of-pocket spend?
  2. When there are no other money requests, only a tracking one, it will look like this (showing only Total), are we ok with this?
image image

paultsimura avatar Mar 29 '24 13:03 paultsimura

First – there is no visual difference between the tracking expense (1st) and the actual money request (2nd) – do we want to change it?

No, as we don't have any such thing in docs. But let me summon @Expensify/design so that they can chime in.

shubham1206agra avatar Mar 29 '24 14:03 shubham1206agra

Do I understand correctly that adding a Tracking Expense inside an Expense Report should increase the Total and Company spend, but not the Out-of-pocket spend?

This is a non-reimbursable expense. That's why it will behave like this.

shubham1206agra avatar Mar 29 '24 14:03 shubham1206agra

When there are no other money requests, only a tracking one, it will look like this (showing only Total), are we ok with this?

Not sure. @thienlnam can confirm this.

shubham1206agra avatar Mar 29 '24 14:03 shubham1206agra

One more thing that bothers me is the Report Preview text.

Currently, if the total looks like this: image

The preview will show plainly "Spent $total": image

Is there any design for what we should show in such cases (when there are reimbursable and non-reimbursable requests combined)?

paultsimura avatar Mar 29 '24 14:03 paultsimura

Again @Expensify/design can help here.

shubham1206agra avatar Mar 29 '24 14:03 shubham1206agra

Hmm, I'm really curious for the other designer's thoughts on these.

First – there is no visual difference between the tracking expense (1st) and the actual money request (2nd) – do we want to change it?

For this one, I could maybe see editing the Cash line or maybe just adding a dot separator and appending something there to make it more clear? I'm not sure.

Is there any design for what we should show in such cases (when there are reimbursable and non-reimbursable requests combined)?

This one has me kinda stumped. I don't know that we want to change the preview behavior or create a custom preview for tracked expenses, so I'm not sure if there's a good solution for this.

@Expensify/design any ideas?

dannymcclain avatar Mar 29 '24 14:03 dannymcclain

First – there is no visual difference between the tracking expense (1st) and the actual money request (2nd) – do we want to change it?

Correct - whether you track a personal expense or send someone a money request, they are both just expenses under the hood and they would look the same at the expense level.

Do I understand correctly that adding a Tracking Expense inside an Expense Report should increase the Total and Company spend, but not the Out-of-pocket spend?

I don't understand why we are handling it this way. If you add an expense to a report, it just increases the total. The "Company spend" vs "Out of pocket spend" is just a nicer way of saying "Is this expense reimburseable or not?"

Unless I am missing something. Did the GH issue or design doc specify otherwise?

When there are no other money requests, only a tracking one, it will look like this (showing only Total), are we ok with this?

Yes. We already have existing patterns for what expenses look like when they are added to a workspace, so we just follow what we currently have.

@thienlnam can you also chime in here? Seems like maybe there is some misunderstanding going on.

shawnborton avatar Mar 29 '24 15:03 shawnborton

The "Company spend" vs "Out of pocket spend" is just a nicer way of saying "Is this expense reimburseable or not?"

Yes, from what I understood.

paultsimura avatar Mar 29 '24 17:03 paultsimura

One more BE issue related to money request removal:

  1. Have both non- and reimbursable requests in one Money report
  2. Remove the reimbursable one
  3. Observe that for a moment, the optimistic total is correct
  4. When the DeleteMoneyRequest response comes, see that the total becomes 0
  5. After refreshing the page, see that the total is back to normal.

The DeleteMoneyRequest API returns the iouReport.total: 0 and iouReport.unheldTotal: 0 – this needs to be fixed.

https://github.com/Expensify/App/assets/12595293/24c29b0c-c5c1-4757-b638-dd9430346cd3

paultsimura avatar Mar 30 '24 15:03 paultsimura

@shubham1206agra 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[bot] avatar Mar 30 '24 22:03 melvin-bot[bot]

@shubham1206agra you can start the preliminary testing (just please be aware that the current main has the regular money request flow broken). I will fill out the checklist by Monday.

paultsimura avatar Mar 30 '24 22:03 paultsimura

Screenshot 2024-04-01 at 5 43 08 PM

@paultsimura @Expensify/design Should we show paid sign to non-reimbursable request?

shubham1206agra avatar Apr 01 '24 12:04 shubham1206agra

Hmm did the user take any action to trigger that state? Like did the user mark the report as Paid? If so, then yes.

shawnborton avatar Apr 01 '24 12:04 shawnborton

Yes, I used Pay elsewhere on the report.

shubham1206agra avatar Apr 01 '24 12:04 shubham1206agra

Cool, then I think what you have is correct. We shouldn't really view these as "special" transactions, we should try to treat them like any other expense as best we can.

shawnborton avatar Apr 01 '24 12:04 shawnborton

@shubham1206agra all yours 🙌

paultsimura avatar Apr 01 '24 18:04 paultsimura

Screenshot 2024-04-02 at 7 31 35 AM

@paultsimura @Expensify/design Should I see a GBR indicator on LHN for track expenses on workspace?

shubham1206agra avatar Apr 02 '24 02:04 shubham1206agra

https://github.com/Expensify/App/assets/58412969/d4aefe72-f38a-4545-ac49-04b0deb79d08

@paultsimura I am seeing new message indicator on self DM on creating track expense.

shubham1206agra avatar Apr 02 '24 02:04 shubham1206agra

Should I see a GBR indicator on LHN for track expenses on workspace?

Good question - perhaps bring to Slack for discussion? I feel like if there is no action to take, there shouldn't be a green brick road dot. And I think this should be consistent everywhere, not just the personal tracking case. cc @JmillsExpensify @puneetlath for thoughts

shawnborton avatar Apr 02 '24 06:04 shawnborton

Screenshot 2024-04-02 at 7 31 35 AM @paultsimura Should I see a GBR indicator on LHN for track expenses on workspace?

@paultsimura Can you fix this? There should be no GBR here.

shubham1206agra avatar Apr 02 '24 06:04 shubham1206agra

Can you fix this? There should be no GBR here.

@shubham1206agra this is a BE issue – we do not set the GBR optimistically. After placing the request, an OpenReport API call returns hasOutstandingChildRequest: true for the chat report.

cc: @thienlnam

paultsimura avatar Apr 02 '24 07:04 paultsimura

I am seeing new message indicator on self DM on creating track expense.

This is not related to expense tracking – you will see the same indicator when assigning a new task in the self DM.

paultsimura avatar Apr 02 '24 07:04 paultsimura

@paultsimura Can you merge main here?

shubham1206agra avatar Apr 03 '24 06:04 shubham1206agra

@shubham1206agra done ✔️

paultsimura avatar Apr 03 '24 07:04 paultsimura

@paultsimura BUG: Creating a new track expense after deleting gives skeleton.

https://github.com/Expensify/App/assets/58412969/2cf76906-ea87-4304-9555-17badbd58a5a

shubham1206agra avatar Apr 03 '24 13:04 shubham1206agra