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

[$250] Distance rates - Error shows up when adding distance rates to the workspace created from actionable whisper #51035

Closed
5 of 8 tasks
lanitochka17 opened this issue Oct 17, 2024 · 22 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 17, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.50-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to self DM
  3. Track a manual expense
  4. Click Categorize it from the whisper
  5. Click New workspace
  6. Select a category, proceed to confirmation page and submit it
  7. Go to workspace settings of the new workspace > More features
  8. Enable Distance rates
  9. Go to Distance rates
  10. Add a distance rate

Expected Result:

Distance rates will be added without issue

Actual Result:

Error shows up when adding distance rates to the workspace created from actionable whisper

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6637815_1729178169983.bandicam_2024-10-17_23-09-53-329.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021851723074244556259
  • Upwork Job ID: 1851723074244556259
  • Last Price Increase: 2024-10-30
Issue OwnerCurrent Issue Owner: @shubham1206agra
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

Triggered auto assignment to @anmurali (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@lanitochka17
Copy link
Author

@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@mkzie2
Copy link
Contributor

mkzie2 commented Oct 17, 2024

Proposal

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

Error shows up when adding distance rates to the workspace created from actionable whisper

What is the root cause of that problem?

The error is an invalid ID in the custom unit

Screenshot 2024-10-18 at 00 44 31

The RCA is when we categorize with a new workspace, it's created in frontend with a customUnitID but we don't pass this to the parameter of TrackExpense API then BE returns another customUnitID for the new WS.

const parameters = {

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

If it's the new WS, we've passed some data in createdWorkspaceParams, we can pass additional data customUnitID and customUnitRateID to the parameter. BE also needs to use these parameters to update customUnits data of the workspace if required.

customUnitID: createdWorkspaceParams?.customUnitID,
customUnitRateID: createdWorkspaceParams?.customUnitRateID

App/src/libs/actions/IOU.ts

Lines 3422 to 3425 in 91c6e0c

policyExpenseChatReportID: createdWorkspaceParams?.expenseChatReportID,
policyExpenseCreatedReportActionID: createdWorkspaceParams?.expenseCreatedReportActionID,
adminsChatReportID: createdWorkspaceParams?.adminsChatReportID,
adminsCreatedReportActionID: createdWorkspaceParams?.adminsCreatedReportActionID,

What alternative solutions did you explore? (Optional)

NA

@FitseTLT
Copy link
Contributor

Proposal

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

Distance rates - Error shows up when adding distance rates to the workspace created from actionable whisper

What is the root cause of that problem?

When we press new workspace button a new workspace will be created with customUnits generated in FE onyx only

ReportUtils.createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID, action);

const {expenseChatReportID, policyID, policyName} = PolicyActions.createDraftWorkspace();

now we will have a draft policy in onyx only and when we open the workspace profile page we fetch the policy with that policyID from BE here
Policy.openPolicyProfilePage(route.params.policyID);

so now OPEN_POLICY_PROFILE_PAGE API will return a policy data and it will merge the customUnit that only existed in FE with customUnits from the server. Therefore, when we create a distance rate the customUnitRateID in onyx will be sent but the BE doesn't know it so it returns error

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

By the way, the problem is even more serious: if you finish on categorizing with the new workspace you created in track flow and create the expense but sign out or clear cache before opening the profile page of the new workspace created the workspace along with the expense created from the track expense will be lost as the data was only saved in onyx only not in server.
What we should do is call createWorkspace instead of createDraftWorkspace (that will create the workspace both optimisticData and in server) here

const {expenseChatReportID, policyID, policyName} = PolicyActions.createDraftWorkspace();

similar to what we do when we create workspace in onboarding flow here

    const {expenseChatReportID, policyID, policyName} = PolicyActions.createWorkspace();

We can then remove createDraftWorkspace as we no longer need it.

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Oct 21, 2024
Copy link

melvin-bot bot commented Oct 22, 2024

@anmurali Eep! 4 days overdue now. Issues have feelings too...

Copy link

melvin-bot bot commented Oct 24, 2024

@anmurali 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

Copy link

melvin-bot bot commented Oct 28, 2024

@anmurali 10 days overdue. Is anyone even seeing these? Hello?

Copy link

melvin-bot bot commented Oct 30, 2024

@anmurali 12 days overdue now... This issue's end is nigh!

@anmurali anmurali added the External Added to denote the issue can be worked on by a contributor label Oct 30, 2024
Copy link

melvin-bot bot commented Oct 30, 2024

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

@melvin-bot melvin-bot bot changed the title Distance rates - Error shows up when adding distance rates to the workspace created from actionable whisper [$250] Distance rates - Error shows up when adding distance rates to the workspace created from actionable whisper Oct 30, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 30, 2024
Copy link

melvin-bot bot commented Oct 30, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (External)

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2024
Copy link

melvin-bot bot commented Oct 31, 2024

@anmurali @shubham1206agra this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@shubham1206agra
Copy link
Contributor

Requires internal engineer to add a parameter to fix customUnitID.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Nov 1, 2024

Triggered auto assignment to @Julesssss, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@Julesssss
Copy link
Contributor

Julesssss commented Nov 1, 2024

Thanks both. This is bad, but I'm afraid that backend changes are unlikely to be prioritised anytime soon.

I think for now we should close.

Copy link

melvin-bot bot commented Nov 1, 2024

@Julesssss @anmurali Be sure to fill out the Contact List!

@FitseTLT
Copy link
Contributor

FitseTLT commented Nov 1, 2024

@Julesssss what about #51035 (comment)? I think this should be fixed in the frontend, not only for the current issue but also for other reasons mentioned in the proposal.

@Julesssss
Copy link
Contributor

Yeah I did think you made a good follow up point about the problem becoming worse after going offline. But we'd still need backend changes, no?:

Therefore, when we create a distance rate the customUnitRateID in onyx will be sent but the BE doesn't know it so it returns error

@FitseTLT
Copy link
Contributor

FitseTLT commented Nov 1, 2024

Yeah I did think you made a good follow up point about the problem becoming worse after going offline. But we'd still need backend changes, no?:

@Julesssss No we don't need BE changes.
The new workspace button in the participants page works in a very weird way. It creates the whole data needed for a workspace (including the related reports/rooms) optimstically and the BE knows nothing about it. So the only way the BE would know it is when you open the workplace setting page on which case openProfilePage with that policyID

Policy.openPolicyProfilePage(route.params.policyID);

will be requested and know the new policy data returned from the BE will be merged with the current workspace. BTW openProfilePage is not intended to create a new workpace, it's only intended to load any new changes on existing workspaces.
What we should do
we should use the existing method of creating a workspace similar to what we do when we create workspace in onboarding flow here that would create the necessary optimistic data and send CREATE_WORKSPACE API request to the BE.

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 1, 2024

We only create a draft policy because the user can cancel the flow and the created policy is unnecessary.

@FitseTLT
Copy link
Contributor

FitseTLT commented Nov 1, 2024

We only create a draft policy because the user can cancel the flow and the created policy is unnecessary.

But how we are handling it now is wrong that the root cause of the issue. If we want to discard the workspace when the user cancels the flow we can separately create the optimistic data first and only request create workspace API when the user finishes the flow but clear the optimistic data if the user aborts the flow. That still won't need BE changes.
cc: @Julesssss

@shubham1206agra
Copy link
Contributor

@mkzie2 Can you send me the response of the API?

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 1, 2024

Here is the response when we call OpenPolicyProfilePage API. When we call CategorizeTrackedExpense API, it's only return the admin room data of the WS.

Screenshot 2024-11-01 at 21 17 16

@shubham1206agra
Copy link
Contributor

One possible solution is to clear the old customUnitID for now. One way is to somehow not add the customUnitID at all. But this might create some errors. BE solution is the best.

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 1, 2024

Can we request internal team to do this now?

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 1, 2024

One possible solution is to clear the old customUnitID for now

Or we clear customUnitID in successData of CategorizeTrackedExpense API now.

@shubham1206agra
Copy link
Contributor

One possible solution is to clear the old customUnitID for now

Or we clear customUnitID in successData of CategorizeTrackedExpense API now.

This is problematic since offline distance rates addition will fail.

Copy link

melvin-bot bot commented Dec 12, 2024

⚠️ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

6 participants