Move policy employee list logic to ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST#10461
Conversation
ONYXKEYS.COLLECTION.POLICY_MEMBER_LISTONYXKEYS.COLLECTION.POLICY_MEMBER_LIST
chiragsalian
left a comment
There was a problem hiding this comment.
Mostly LGTM. Left few minor comments. I think we should also make a follow up issue to not get employeeList in the policy object to begin with.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
| role: CONST.POLICY.ROLE.ADMIN, | ||
| outputCurrency: response.policy.outputCurrency, | ||
| }), | ||
| Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST}${response.policyID}`, getSimplifiedEmployeeList(response.policy.employeeList)), |
There was a problem hiding this comment.
Is it necessary to have both of these inside the promise.all? I don't think it matters when the member list is merged, does it? It also doesn't seem like it matters when the policy object is merged.
The only time the promise returned from create() is used is to navigate to the policy, but I don't think any of that requires the policy stuff to be merged into Onyx yet, does it?
There was a problem hiding this comment.
The policy data would need to be merged otherwise the workspace page would briefly open as "Not Found" until the Onyx update finishes. I included the members list here also just to be safe. The functionality here is very temporary since it'll be replaced by incoming workspace refactors so I wouldn't lose too much sleep optimizing it.
There was a problem hiding this comment.
OK, while I am fine not doing anything since it's only temporary, I do think it's important to always make clear and appropriate choices with code, regardless of how long it's going to live.
| previousRoutePolicyID = policyID; | ||
|
|
||
| const rest = _.omit(props, ['forwardedRef', 'policy']); | ||
| const rest = _.omit(props, ['forwardedRef', 'policy', 'policyMemberList']); |
There was a problem hiding this comment.
Why are policy and policyMemberList removed from props, only to be added directly as props below? I think that forwardedRef is the only one that needs removed from props because it needs to be renamed to ref
There was a problem hiding this comment.
Honestly not sure about this one I just followed the existing pattern. I'll see if it makes a difference
|
Tests passing in staging 👍 |
| return Promise.all( | ||
| Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${response.policyID}`, { |
There was a problem hiding this comment.
FYI, There is a regression from this change #10667
Promise.all accepts a single param as iterable.
There was a problem hiding this comment.
FYI @arosiclair I'm planning to hire a contributor to fix this, in #10665
There was a problem hiding this comment.
JK it was fixed elsewhere :D
Details
Points employee list logic to
ONYXKEYS.COLLECTION.POLICY_MEMBER_LISTfor loading and creating policies as well as inviting and removing membersFixed Issues
$ https://github.com/Expensify/Expensify/issues/223499
Tests
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)PR Reviewer Checklist
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Screenshots
Web
Screen.Recording.2022-08-19.at.4.46.52.PM.mov
Mobile Web
Desktop
iOS
Android