feat: Expense Tracking in the Workspace Chat
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 Issuessection above - [ ] I wrote clear testing steps that cover the changes made in this PR
- [ ] I added steps for local testing in the
Testssection - [ ] I added steps for the expected offline behavior in the
Offline stepssection - [ ] I added steps for Staging and/or Production testing in the
QA stepssection - [ ] 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 added steps for local testing in the
- [ ] 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.
toggleReportand notonIconClick) - [ ] 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
- [ ] 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.
- [ ] 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 usingAvatarare 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
Avataris modified, I verified thatAvataris 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
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- [ ] If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - [ ] If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.
Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop
I've created this draft PR to start tracking the existing issues that are blocking the PR, but are not directly related to it.
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
@thienlnam could you please help with adding the corresponding label or tagging relevant people?
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
Yes it's a known issue @thienlnam is working on this
A couple more things I'd like to clarify:
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.
- Do I understand correctly that adding a Tracking Expense inside an Expense Report should increase the
TotalandCompany spend, but not theOut-of-pocket spend? - When there are no other money requests, only a tracking one, it will look like this (showing only Total), are we ok with this?
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.
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.
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.
One more thing that bothers me is the Report Preview text.
Currently, if the total looks like this:
The preview will show plainly "Spent $total":
Is there any design for what we should show in such cases (when there are reimbursable and non-reimbursable requests combined)?
Again @Expensify/design can help here.
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?
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.
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.
One more BE issue related to money request removal:
- Have both non- and reimbursable requests in one Money report
- Remove the reimbursable one
- Observe that for a moment, the optimistic total is correct
- When the
DeleteMoneyRequestresponse comes, see that the total becomes0 - 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
@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]
@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 @Expensify/design Should we show paid sign to non-reimbursable request?
Hmm did the user take any action to trigger that state? Like did the user mark the report as Paid? If so, then yes.
Yes, I used Pay elsewhere on the report.
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.
@shubham1206agra all yours 🙌
@paultsimura @Expensify/design Should I see a GBR indicator on LHN for track expenses on workspace?
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.
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
@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.
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
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 Can you merge main here?
@shubham1206agra done ✔️
@paultsimura BUG: Creating a new track expense after deleting gives skeleton.
https://github.com/Expensify/App/assets/58412969/2cf76906-ea87-4304-9555-17badbd58a5a
@paultsimura Should I see a GBR indicator on LHN for track expenses on workspace?