Skip to content
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 member option appear in transaction thread report detail page #42036

Merged
merged 7 commits into from
May 28, 2024
Merged
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
27 changes: 17 additions & 10 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,14 @@ function isSystemChat(report: OnyxEntry<Report>): boolean {
return getChatType(report) === CONST.REPORT.CHAT_TYPE.SYSTEM;
}

/**
* Checks if a report is an IOU or expense report.
*/
function isMoneyRequestReport(reportOrID: OnyxEntry<Report> | EmptyObject | string): boolean {
const report = typeof reportOrID === 'object' ? reportOrID : allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`] ?? null;
return isIOUReport(report) || isExpenseReport(report);
}

/**
* Only returns true if this is our main 1:1 DM report with Concierge
*/
Expand Down Expand Up @@ -1217,7 +1225,7 @@ function hasExpenses(reportID?: string): boolean {
* Whether the provided report is a closed expense report with no expenses
*/
function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>): boolean {
return report?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED && isExpenseReport(report) && !hasExpenses(report.reportID);
return report?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED && isMoneyRequestReport(report) && !hasExpenses(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.

Same doubt, why this change?

}

/**
Expand Down Expand Up @@ -1394,14 +1402,6 @@ function isMoneyRequest(reportOrID: OnyxEntry<Report> | string): boolean {
return isIOURequest(report) || isExpenseRequest(report);
}

/**
* Checks if a report is an IOU or expense report.
*/
function isMoneyRequestReport(reportOrID: OnyxEntry<Report> | EmptyObject | string): boolean {
const report = typeof reportOrID === 'object' ? reportOrID : allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportOrID}`] ?? null;
return isIOUReport(report) || isExpenseReport(report);
}

/**
* Checks if a report has only one transaction associated with it
*/
Expand Down Expand Up @@ -1499,6 +1499,10 @@ function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): bool
return false;
}

if (moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@nkdengineer Why do we need this change?

return false;
}

if (isReportApproved(moneyRequestReport) || isSettled(moneyRequestReport?.reportID)) {
return false;
}
Expand Down Expand Up @@ -4309,10 +4313,11 @@ function buildOptimisticChatReport(
description = '',
avatarUrl = '',
optimisticReportID = '',
shouldShowParticipants = true,
): OptimisticChatReport {
const participants = participantList.reduce((reportParticipants: Participants, accountID: number) => {
const participant: ReportParticipant = {
hidden: false,
hidden: !shouldShowParticipants,
role: accountID === currentUserAccountID ? CONST.REPORT.ROLE.ADMIN : CONST.REPORT.ROLE.MEMBER,
};
// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -4859,6 +4864,8 @@ function buildTransactionThread(
moneyRequestReport?.reportID,
'',
'',
'',
false,
);
}

Expand Down
Loading