-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix - Approve button not disappear after approving report offline if advanced approval set #49188
Fix - Approve button not disappear after approving report offline if advanced approval set #49188
Conversation
@mananjadhav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
const submitToAccountID = PolicyUtils.getSubmitToAccountID(policy, ownerAccountID); | ||
|
||
if (approvalChain.length === 0) { | ||
return submitToAccountID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need any additional checks for submitAccountID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this logic is taken from how we get the next approver display name to build next step here as what we are aiming to achieve is to set the managerID to the next approver. And getSubmitToAccountID
always returns account number
so we don't need any checks.
Line 7030 in 00bc167
const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, predictedNextStatus); |
Line 96 in 00bc167
const nextApproverDisplayName = getNextApproverDisplayName(policy, ownerAccountID, submitToAccountID, report); |
Lines 63 to 74 in 00bc167
function getNextApproverDisplayName(policy: Policy, ownerAccountID: number, submitToAccountID: number, report: OnyxEntry<Report>) { | |
const approvalChain = ReportUtils.getApprovalChain(policy, ownerAccountID, report?.total ?? 0); | |
if (approvalChain.length === 0) { | |
return ReportUtils.getDisplayNameForParticipant(submitToAccountID); | |
} | |
const nextApproverEmail = approvalChain.length === 1 ? approvalChain[0] : approvalChain[approvalChain.indexOf(currentUserEmail) + 1]; | |
if (!nextApproverEmail) { | |
return ReportUtils.getDisplayNameForParticipant(submitToAccountID); | |
} | |
return PersonalDetailsUtils.getPersonalDetailByEmail(nextApproverEmail)?.displayName ?? nextApproverEmail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we got the logic from there can we refactor this so we don't need to maintain two very similar utils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the getNextApproverDisplayName()
can get the nextApproverAccountID
and use it to get the displayName
?
src/libs/actions/IOU.ts
Outdated
return submitToAccountID; | ||
} | ||
|
||
return PersonalDetailsUtils.getAccountIDsByLogins([nextApproverEmail])[0] ?? submitToAccountID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add a length check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need; there is already a fallback provided in case of empty array 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall code changes looks good, asked 2 questions.
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-approval.movAndroid: mWeb Chromemweb-chrome-approval.moviOS: Nativeios-approval.moviOS: mWeb Safarimweb-safari-approval.movMacOS: Chrome / Safariweb-approval.movMacOS: Desktopdesktop-approval.mov |
Is it possible to generate adhoc builds for this one? I am having issues with mobile app builds. |
@mananjadhav requested ad hoc build 👍 |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
|
Thanks @dylanexpensify testing this. |
const submitToAccountID = PolicyUtils.getSubmitToAccountID(policy, ownerAccountID); | ||
|
||
if (approvalChain.length === 0) { | ||
return submitToAccountID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we got the logic from there can we refactor this so we don't need to maintain two very similar utils?
const submitToAccountID = PolicyUtils.getSubmitToAccountID(policy, ownerAccountID); | ||
|
||
if (approvalChain.length === 0) { | ||
return submitToAccountID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the getNextApproverDisplayName()
can get the nextApproverAccountID
and use it to get the displayName
?
Correct @marcaaron I have implemented it and tests well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes, thanks!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/marcaaron in version: 9.0.41-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.0.41-10 🚀
|
Details
Fixed Issues
$ #47264
PROPOSAL: #47264 (comment)
Tests
Precondition: create a control workspace, set "Manually approve all expenses" over to $10 and set advanced approval in OD:
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
a.mp4
Android: mWeb Chrome
aw.mp4
iOS: Native
i.mp4
iOS: mWeb Safari
iw.mp4
MacOS: Chrome / Safari
w.mp4
MacOS: Desktop
d.mp4