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

Refactor of WorkspaceReimburseView to use new API #10692

Merged
merged 10 commits into from
Sep 1, 2022

Conversation

yuwenmemon
Copy link
Contributor

@arosiclair please review
cc @ctkochan22

Details

Refactor WorkspaceReimburseView to use the new API

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/217856

Tests/QA

  1. Open the Reimburse Expenses page by going to Settings -> [Workspace] -> Reimburse expenses
  2. Make sure that the Mileage rate displays the value you have in your policy
  3. Make sure that when you open the selector it shows the mileage setting you have in your policy.
  4. Edit the milage rate, make sure that the value saves and appears the same when you exit, refresh the page, and re-enter the Reimburse expenses view again
  5. Do the same for the mi/km selector

@yuwenmemon yuwenmemon requested a review from arosiclair August 30, 2022 16:37
@yuwenmemon yuwenmemon self-assigned this Aug 30, 2022
@yuwenmemon yuwenmemon requested a review from a team as a code owner August 30, 2022 16:37
@melvin-bot melvin-bot bot requested review from marcochavezf and removed request for a team August 30, 2022 16:37
@yuwenmemon
Copy link
Contributor Author

@arosiclair Have we considered the offline behavior for this? Currently as set up if we're offline we just show a 0.000 rate and mi:

Screen Shot 2022-08-30 at 6 38 26 PM

@yuwenmemon yuwenmemon force-pushed the yuwen-workspaceReimbursePage branch from 83f626b to a90120b Compare August 30, 2022 16:53
@arosiclair
Copy link
Contributor

Have we considered the offline behavior for this? Currently as set up if we're offline we just show a 0.000 rate

This is for when you have not previously viewed the custom unit while online correct? If so, that's expected since we don't have any rate saved in Onyx to display. If you did previously view the custom unit while online, then the same value should display after going offline.

@yuwenmemon
Copy link
Contributor Author

This is for when you have not previously viewed the custom unit while online correct? If so, that's expected since we don't have any rate saved in Onyx to display. If you did previously view the custom unit while online, then the same value should display after going offline.

Yep, that's correct - and sounds good! This is ready to be reviewed

Comment on lines +96 to +110
if (prevProps.policy.customUnits !== this.props.policy.customUnits) {
const distanceCustomUnit = _.chain(lodashGet(this.props, 'policy.customUnits', []))
.values()
.findWhere({name: CONST.CUSTOM_UNITS.NAME_DISTANCE})
.value();

this.setState({
unitID: lodashGet(distanceCustomUnit, 'customUnitID', ''),
unitName: lodashGet(distanceCustomUnit, 'name', ''),
unitValue: lodashGet(distanceCustomUnit, 'attributes.unit', 'mi'),
rateID: lodashGet(distanceCustomUnit, 'rates[0].customUnitRateID', ''),
rateName: lodashGet(distanceCustomUnit, 'rates[0].name', ''),
rateValue: this.getRateDisplayValue(lodashGet(distanceCustomUnit, 'rates[0].rate', 0) / 100),
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Why don't we use the props directly? I think it will be a bit hard to keep props and state in sync if we add more props in the future, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm trying to have as little impact on this aspect of the page as possible and simply support the new API command. It's been worked on by a number of contributors based on what I've seen. I agree it could use some improvement in how it's written but I feel like that would be the domain of a follow-up issue.

@marcochavezf
Copy link
Contributor

marcochavezf commented Aug 31, 2022

I noticed that after refreshing the browser, the unit value changes quickly to the previous value (Kilometers -> Miles -> Kilometers), I wonder if it would be related to the props - state sync

Screen.Recording.2022-08-31.at.12.47.39.mov

@yuwenmemon
Copy link
Contributor Author

Yeah, cc @arosiclair but I would guess that's by design since the doc states we use componentDidMount to make the call and load the rate. So it's most likely coming from there. Is this how we intended it?

Copy link
Contributor

@arosiclair arosiclair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the componentDidUpdate logic is conflicting with getDerivedStateFromProps since they're both trying to set the same state. I tested removing getDerivedStateFromProps and it fixed the kilometers-miles flickering on refresh so I think we should just remove it

@yuwenmemon
Copy link
Contributor Author

Sounds good, and added!

@arosiclair arosiclair merged commit ffa839e into main Sep 1, 2022
@arosiclair arosiclair deleted the yuwen-workspaceReimbursePage branch September 1, 2022 14:17
@OSBotify
Copy link
Contributor

OSBotify commented Sep 1, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Sep 5, 2022

🚀 Deployed to staging by @arosiclair in version: 1.1.97-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@mvtglobally
Copy link

Tester is facing a different issue now when re-testing. the error doesn't disappear after appearing. We are collecting more info to see if it needs to be logged

Recording.1797.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants