Skip to content

Fix - Scan receipt - Red dot missing on LHN after receipt edit & submit with higher Amount #60867

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ type GetReportNameParams = {
policies?: SearchPolicy[];
};

type ReportByPolicyMap = Record<string, Report[]>;
type ReportByPolicyMap = Record<string, string[]>;

let currentUserEmail: string | undefined;
let currentUserPrivateDomain: string | undefined;
Expand Down Expand Up @@ -888,7 +888,7 @@ Onyx.connect({
});

let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
let reportIDsByPolicyID: ReportByPolicyMap;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
Expand All @@ -905,7 +905,7 @@ Onyx.connect({
return;
}

reportsByPolicyID = Object.values(value).reduce<ReportByPolicyMap>((acc, report) => {
reportIDsByPolicyID = Object.values(value).reduce<ReportByPolicyMap>((acc, report) => {
if (!report) {
return acc;
}
Expand All @@ -914,13 +914,13 @@ Onyx.connect({

// Get all reports, which are the ones that are:
// - Owned by the same user
// - Are either open or submitted
// - Are not settled.
Copy link
Contributor

Choose a reason for hiding this comment

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

So if I'm a submitter on a workspace that has both approvals and payments enabled. And I submit an expense that has this violation and it gets approved, but hasn't been paid yet, will I still see the RBR on my workspace chat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it will only disappear after it is paid out.

// - Belong to the same workspace
if (report.policyID && report.ownerAccountID === currentUserAccountID && (report.stateNum ?? 0) <= 1) {
if (report.policyID && report.ownerAccountID === currentUserAccountID && !isSettled(report)) {
if (!acc[report.policyID]) {
acc[report.policyID] = [];
}
acc[report.policyID].push(report);
acc[report.policyID].push(report.reportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have any explanation for using reportID instead of report?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its just refactoring @hungvu193 As we are using only the report id no need to save the whole report data. 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Can you merge main again?

}

return acc;
Expand Down Expand Up @@ -7497,17 +7497,17 @@ function shouldDisplayViolationsRBRInLHN(report: OnyxEntry<Report>, transactionV
if (!isCurrentUserSubmitter(report.reportID)) {
return false;
}
if (!report.policyID || !reportsByPolicyID) {
if (!report.policyID || !reportIDsByPolicyID) {
return false;
}

// If any report has a violation, then it should have a RBR
const potentialReports = reportsByPolicyID[report.policyID] ?? [];
return potentialReports.some((potentialReport) => {
const potentialReportIDs = reportIDsByPolicyID[report.policyID] ?? [];
return potentialReportIDs.some((reportID) => {
return (
hasViolations(potentialReport.reportID, transactionViolations, true) ||
hasWarningTypeViolations(potentialReport.reportID, transactionViolations, true) ||
hasNoticeTypeViolations(potentialReport.reportID, transactionViolations, true)
hasViolations(reportID, transactionViolations, true) ||
hasWarningTypeViolations(reportID, transactionViolations, true) ||
hasNoticeTypeViolations(reportID, transactionViolations, true)
);
});
}
Expand Down
Loading