-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: report field not disabled for per diem requests with no outstanding reports #77963
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
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
| return ( | ||
| !isArchivedReport(reportNameValuePair) && | ||
| isReportOutstanding(report, report?.policyID, reportNameValuePairs, false) && | ||
| (isPerDiemRequest ? report?.policyID === policy?.id && canSubmitPerDiemExpenseFromWorkspace(allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]) : true) |
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.
❌ PERF-2 (docs)
The expensive isReportOutstanding function is called before checking the simple property comparison report?.policyID === policy?.id when isPerDiemRequest is true. This forces the expensive function to run on all reports, even those that will be filtered out by the simple check.
Move the simple policyID check before the expensive operation:
return outstandingReports.filter((report) => {
const reportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`];
// Early return for perDiem requests with mismatched policyID
if (isPerDiemRequest && report?.policyID \!== policy?.id) {
return false;
}
return (
\!isArchivedReport(reportNameValuePair) &&
isReportOutstanding(report, report?.policyID, reportNameValuePairs, false) &&
(\!isPerDiemRequest || canSubmitPerDiemExpenseFromWorkspace(allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]))
);
});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.
done
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
|
||
| // When creating an expense in an individual report, the report field becomes read-only | ||
| // since the destination is already determined and there's no need to show a selectable list. | ||
| const shouldReportBeEditable = (isFromGlobalCreate ? shouldReportBeEditableFromFAB : availableOutstandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports); |
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.
| const shouldReportBeEditable = (isFromGlobalCreate && !isPerDiemRequest ? shouldReportBeEditableFromFAB : availableOutstandingReports.length > 1) && !isMoneyRequestReport(reportID, allReports); |
@Burhan-Rashid Alternatively, we can just make the above change to consider availableOutstandingReports for perDiemRequest which is derived with getOutstandingReportsForUser of the specific selected policyId. With this, we can take out the other changes you committed in this file. WDYT?
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.
sure, we can do that. Let me test these changes once for different use cases and will update after that. Thanks
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.
done pushed the changes. i tested the changes and it is working fine @Pujan92
| const {policyForMovingExpenses} = usePolicyForMovingExpenses(isPerDiemRequest); | ||
|
|
||
| const perDiemOriginalPolicy = getPolicyByCustomUnitID(firstTransaction, allPolicies); | ||
| const perDiemOriginalPolicy = getPolicyByCustomUnitID(firstTransaction ?? draftTransaction, allPolicies); |
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.
@Pujan92 Should i keep these changes in this PR or should we create a seperate issue and seperate PR for this one.
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.
Let's revert this as it will be handled in #77923
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.
sure done
|
Can you try to make your PR titles more reflective of what code changes the PR is making / fill out the explanation of changes section? Thanks! CC: @cristipaval @koko57 for vis as well. |
sure, filled the explanation of change section. |
|
Thanks!
Why |
The issue here was the report field was not disabled for per diem expenses when there were no outstanding reports for that particular workspace in which user was creating the per diem expense, but when user clicked on the report field, there were no report options for him to select, that is why we need to disable the field when there are no report options available for the user. Because we only show the outstanding reports of that particular workspace in case of per diem expenses according to the code here: App/src/pages/iou/request/step/IOURequestEditReportCommon.tsx Lines 169 to 178 in 5be3e2c
|
|
I'll wait for the engineers to chime in, I think the terminology "outstanding" is confusing me here, because it's the name of a specific report state. |
|
@trjExpensify isn't the "outstanding" term correct here which is either the report is in an open or submitted state but not yet approved? |
|
Test steps are wrong. How can we create a per diem expense in workspace B when per diem feature is disabled? |
Steps are correct @parasharrajat. we only need to create 2 empty reports in workspace B(non per diem workspace) not per diem expenses. |
|
Thanks @parasharrajat for pointing that out. We can update the steps to Precondition: Workspace A has per diem rates.
|
nah,
|
@Pujan92 if we follow these steps in current production version, we won't be able to reproduce this issue. |
|
Oh yes, @Burhan-Rashid. we need available reports into any other workspace step |
Ah, Yes @trjExpensify, we can think of the function name update. As in the code, based on the condition( Lines 11445 to 11470 in 3210952
|
|
@Burhan-Rashid Plz merge main |
Pujan92
left a 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.
LGTM!
Screen.Recording.2025-12-20.at.11.09.44.mov
|
@Pujan92 There was eslint failure on the previous PR run. i have added comments for disabling the eslint for the deprecated function in this file. It was related to this function getReportName. |
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| const name = getReportName(selectedReport, selectedPolicy); |
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.
Let's use the computeName like the below change instead of disabling it.
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.
done
|
@justinpersaud Plz consider checking the comments here #77963 (comment). The "outstanding" term is used extensively(for derived onyx key too) in all those places from this PR. |
|
@trjExpensify the term outstanding is probably wrong here but the changes here aren't what introduced it. If we want to change it for house keeping, we should probably tackle that separately and not block on that here. Changes look fine to me. |
|
Friendly bump for review @trjExpensify |
|
@trjExpensify let me know if you're fine with what I said above and I can merge if so |
|
Friendly bump @trjExpensify #77963 (comment) |
|
I'm cool with that @justinpersaud. Sorry for the delay, I was OoO for the holidays. |
|
✋ 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/justinpersaud in version: 9.2.94-0 🚀
|
fix: report field not disabled for per diem requests with no outstanding reports
|
🚀 Deployed to production by https://github.com/arosiclair in version: 9.2.94-4 🚀
|

Explanation of Change
While creating per diem requests from global FAB, We should disable the report field on confirmation page if there are no outstanding reports in the workspace in which we are creating the per diem expense.
Fixed Issues
$#76205
PROPOSAL:#76205 (comment)
Tests
Precondition:
Create two workspaces - Workspace A and B.
Workspace A has per diem rates.
Workspace B does not have per diem rates (do not enable Per diem).
Offline tests
Same as tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.native.mp4
Android: mWeb Chrome
andriod.web.mp4
iOS: Native
ios.native.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
mac.web.mp4