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.57k stars 2.91k forks source link

[$250] Tags - State filed is not auto populated. #52879

Open izarutskaya opened 1 day ago

izarutskaya commented 1 day ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.0.65-1 Reproducible in staging?: Y Reproducible in production?: Y Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team

Action Performed:

Pre-condition: upload dependent tags in old dot as admin

Dependent.-.Multi.Level.tags.NEW.1.csv

  1. Go to https://staging.new.expensify.com/
  2. Login as employee
  3. Open employee workspace chat
  4. Tap plus icon - create expense
  5. Enter an amount and tap next

Expected Result:

State field must be auto populated.

Actual Result:

State filed is not auto populated.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/914046c6-8bc8-4fb5-8091-7e45b133c5e9

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021859625825867558770
  • Upwork Job ID: 1859625825867558770
  • Last Price Increase: 2024-11-21
Issue OwnerCurrent Issue Owner: @s77rt
melvin-bot[bot] commented 1 day ago

Triggered auto assignment to @garrettmknight (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.

melvin-bot[bot] commented 19 hours ago

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

melvin-bot[bot] commented 19 hours ago

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

mkzie2 commented 19 hours ago

Proposal

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

State filed is not auto populated.

What is the root cause of that problem?

The transaction and transactionDraft are getting from useOnyx. The data can be not available at the first render in IOURequestStepConfirmation

https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/pages/iou/request/step/withFullTransactionOrNotFound.tsx#L57-L58

It leads transaction prop is undefined at the first time IOURequestStepConfirmation is rendered https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/pages/iou/request/step/IOURequestStepConfirmation.tsx#L642

And this useEffect call setMoneyRequestTag with transactionID is -1 here https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/components/MoneyRequestConfirmationList.tsx#L696-L697

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

We have some options to resolve this bug

  1. Introduce transactionID prop in MoneyRequestConfirmationList and pass transactionID={transactionID} from IOURequestStepConfirmation to MoneyRequestConfirmationList and remove this line. We used transactionID from route param in IOURequestStepConfirmation so I think it makes sense if we also use this in MoneyRequestConfirmationList

https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/pages/iou/request/step/IOURequestStepConfirmation.tsx#L642

  1. In this HOC, return the loading screen if the onyx value is loading. Or we can pass isLoadingTransactionValue prop from withFullTransactionOrNotFound to the component. And we can pass this to MoneyRequestConfirmationList through IOURequestStepConfirmation

https://github.com/Expensify/App/blob/3611198a932189628b23128f9f6888e200605298/src/pages/iou/request/step/withFullTransactionOrNotFound.tsx#L47

Then we can return early in this useEffect if isLoadingTransactionValue is true and run this again after isLoadingTransactionValue is changed to false https://github.com/Expensify/App/blob/e9e18573960d492a29b2563237024f0dc3c37f85/src/components/MoneyRequestConfirmationList.tsx#L696-L697

We should do the same for the auto-populated category

What alternative solutions did you explore? (Optional)

s77rt commented 16 hours ago

I'm not sure I see the bug here. Why must the state be auto populated? is this coming from a regression test? cc @garrettmknight

mkzie2 commented 16 hours ago

@s77rt If you reload the confirmation page, you can see it's auto-populated. It should be populated if the tag is required and the enabledTags has only one