Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.54k stars 2.89k forks source link

[HOLD for payment 2024-04-25] [$500] [Track Expense] Adding Track Expense to Workspace Chats #38971

Closed thienlnam closed 6 months ago

thienlnam commented 7 months ago

In this PR, we added the ability for you to track expenses from the global create / selfDM. These would go directly to your self-DM.

In the context menu for a workspace chat, we're going to also add the ability to track expenses. This won't go to your self-DM, but these transactions will instead be added to the new / existing money request chat of the workspace chat.

Screenshot 2024-03-25 at 5 12 22β€―PM

TrackExpense uses the same parameters as RequestMoney so they should be used in the same way

amount
currency,
comment,
created,
merchant,
iouReportID
chatReportID
transactionID,
reportActionID
createdChatReportActionID
createdIOUReportActionID
reportPreviewReportActionID
receipt
category,
tag,
receiptID
transactionThreadReportID
createdReportActionIDForThread
taxCode,
taxAmount
gpsPoints,

Something to note here is that for the self-DM, we created IOU reportActions directly on the chat report. However, when we're tracking in a workspace chat - the handling will be very similar to the request money flow where the IOU reportAction is added to the expense report. The only difference is that creating a tracked expense will just add a non-reimbursable expense to the report, so it shouldn't adjust change how much is owed

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0118fd1f0c99c73336
  • Upwork Job ID: 1772417470222831616
  • Last Price Increase: 2024-03-26
  • Automatic offers:
    • shubham1206agra | Reviewer | 0
    • paultsimura | Contributor | 0
melvin-bot[bot] commented 7 months ago

Job added to Upwork: https://www.upwork.com/jobs/~0118fd1f0c99c73336

melvin-bot[bot] commented 7 months ago

Current assignee @shubham1206agra is eligible for the External assigner, not assigning anyone new.

thienlnam commented 7 months ago

@shubham1206agra Having you C+ this one since you did the Track Expense on the self-DM and have the context

ShridharGoel commented 7 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Adding Track Expense to Workspace Chats.

What is the root cause of that problem?

New feature.

What changes do you think we should make in order to solve the problem?

This check is currently commented in ReportUtils, we can add it back:

if (canUseTrackExpense && isPolicyExpenseChat(report) && report?.isOwnPolicyExpenseChat) {
   options = [...options, CONST.IOU.TYPE.TRACK_EXPENSE];
}

Now, the track expense option will start showing for workspaces.

The UI and click handling is already handled in AttachmentPickerWithMenuItems.tsx.

[CONST.IOU.TYPE.TRACK_EXPENSE]: {
    icon: Expensicons.DocumentPlus,
    text: translate('iou.trackExpense'),
    onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, report?.reportID ?? ''),
}

The only difference is that creating a tracked expense will just add a non-reimbursable expense to the report, so it shouldn't adjust change how much is owed

This would probably need backend changes as well.

tienifr commented 7 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

We should allow Track Expense in Workspace Chats

What is the root cause of that problem?

This is a new feature.

What changes do you think we should make in order to solve the problem?

  1. Uncomment these lines so that the Track Expense option will show up in the context menu of a workspace chat
  2. In here, add the logic to get the correct IOU report to track the expense. We can do it similar to existing logic for money request here
  3. Below there Use the iouReport when constructing the expense to track, just like we did in getMoneyRequestInformation, there'll be a couple of related methods that need to be updated to add support for the iouReport, like buildOnyxDataForTrackExpense
  4. Since now we're operating on a workspace chat, the report preview also needs to be created/updated optimistically when tracking the expense, similar to what we did with the money request here.
  5. The iouReport created above will also need to be returned here to populate the API request here
  6. In related operation like deleteTrackExpense, we need to handle to update the IOU report/report preview as well, similar to what we did when deleting the money request here
  7. There might back-end changes required to enable this use case

Those are the main changes required, since there're a lot of changes needed in those steps, I'll be happy to provide a test branch if requested.

What alternative solutions did you explore? (Optional)

NA

Result

Screenshot 2024-03-26 at 2 50 08β€―PM
shubham1206agra commented 7 months ago

@tienifr Can you provide a test branch here?

tienifr commented 7 months ago

@tienifr Can you provide a test branch here?

@shubham1206agra I'll provide one within 24 hours, thanks!

tienifr commented 7 months ago

@shubham1206agra Here's the test branch https://github.com/tienifr/App/tree/fix/38971

Please note this requires quite many changes so the branch is a rough branch as a POC for the solution, so it's incomplete and could have bugs/regressions (which will be addressed during PR phase).

Thanks!

melvin-bot[bot] commented 7 months ago

πŸ“£ @shubham1206agra πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 7 months ago

πŸ“£ @paultsimura πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

melvin-bot[bot] commented 7 months ago

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

melvin-bot[bot] commented 6 months ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 6 months ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.4.62-17 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-04-25. :confetti_ball:

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 6 months ago

Issue is ready for payment but no BZ is assigned. @isabelastisser you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

isabelastisser commented 6 months ago

@paultsimura, your payment has now been processed in Upwork.

@shubham1206agra, please accept the offer, and I will process the payment. Note that the Upwork offer expires tomorrow, April 27th. I will DM you for visibility. Thanks!