-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Clear hold reason of all transactions when the admin approves all requests #39579
Conversation
@hoangzinh 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] |
@hoangzinh Actually, after we hold the request, the app crashes the context here. To test locally, we can update these like this
|
src/libs/actions/IOU.ts
Outdated
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${heldTransaction.transactionID}`, | ||
value: { | ||
comment: { | ||
...heldTransaction.comment, |
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.
I think we don't need to push current value of heldTransaction.comment
src/libs/actions/IOU.ts
Outdated
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${heldTransaction.transactionID}`, | ||
value: { | ||
comment: { | ||
...heldTransaction.comment, |
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.
Same 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.
@hoangzinh Updated.
src/libs/actions/IOU.ts
Outdated
@@ -4673,7 +4673,10 @@ function hasIOUToApproveOrPay(chatReport: OnyxEntry<OnyxTypes.Report> | EmptyObj | |||
function approveMoneyRequest(expenseReport: OnyxTypes.Report | EmptyObject, full?: boolean) { | |||
const currentNextStep = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`] ?? null; | |||
let total = expenseReport.total ?? 0; | |||
if (ReportUtils.hasHeldExpenses(expenseReport.reportID) && !full && !!expenseReport.unheldTotal) { | |||
const transactions = TransactionUtils.getAllReportTransactions(expenseReport.reportID); | |||
const hasHeldExpenses = transactions.some((transaction) => TransactionUtils.isOnHold(transaction)); |
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.
I think it's better if we keep use ReportUtils.hasHeldExpenses
util to check report has held expenses. We might need to write a new util to get heldExpenses of a report.
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.
Because ReportUtils.hasHeldExpenses also get all transaction and use it to check the held request and we also use allTransactions here to get the heldTransactions, so I not use ReportUtils.hasHeldExpenses to prevent call getAllReportTransactions
two times.
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.
I think it's not worth to duplicate code ReportUtils.hasHeldExpenses
here. If we put more logic into ReportUtils.hasHeldExpenses
later, those line of codes would be outdated
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.
@hoangzinh I updated.
src/libs/actions/IOU.ts
Outdated
@@ -4729,6 +4729,31 @@ function approveMoneyRequest(expenseReport: OnyxTypes.Report | EmptyObject, full | |||
}, | |||
]; | |||
|
|||
// Clear hold reason of all transactions if we approve all requests | |||
const heldTransactions = ReportUtils.getAllHeldTransactions(expenseReport.reportID); |
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.
@nkdengineer what do you think if we split this into a const and use it to check here? Something like this
Line 4637 in eeccc2b
if (ReportUtils.hasHeldExpenses(expenseReport.reportID) && !full && !!expenseReport.unheldTotal) { |
const hasHeldExpenses = ReportUtils.hasHeldExpenses(expenseReport.reportID)
...
// Clear hold reason of all held transactions if we approve all requests
if (full & hasHeldExpenses) {
const heldTransactions = ReportUtils.getAllHeldTransactions(expenseReport.reportID);
...
}
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.
make sense.
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.
@hoangzinh Updated.
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-04-11.at.15.46.57.android.movAndroid: mWeb ChromeScreen.Recording.2024-04-11.at.15.27.32.android.chrome.moviOS: NativeScreen.Recording.2024-04-11.at.15.33.22.ios.moviOS: mWeb SafariScreen.Recording.2024-04-11.at.15.36.27.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-04-10.at.19.55.30.web.movMacOS: DesktopScreen.Recording.2024-04-11.at.09.03.44.desktop.mov |
@nkdengineer can you try to merge latest main if it fix perf-test? |
@hoangzinh Fixed now. |
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.
LGTM
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.
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/robertjchen in version: 1.4.63-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀
|
Details
Clear hold reason of all transactions when the admin approves all requests
Fixed Issues
$ #39342
PROPOSAL: #39342 (comment)
Tests
Precondition: The admin have the collect workspace and invite some users as employee
Offline tests
Precondition: Do step 1-3 online
Do step 4 - 6 offline
QA Steps
Precondition: The admin have the collect workspace and invite some users as employee
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
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
Screen.Recording.2024-04-04.at.14.31.10.mov
Android: mWeb Chrome
Screen.Recording.2024-04-04.at.14.23.22.mov
iOS: Native
Screen.Recording.2024-04-04.at.14.32.28.mov
iOS: mWeb Safari
Screen.Recording.2024-04-04.at.14.27.38.mov
MacOS: Chrome / Safari
Screen.Recording.2024-04-04.at.13.37.46.mov
MacOS: Desktop
Screen.Recording.2024-04-04.at.14.35.24.mov