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 - Expense - Submit button appears for archived workspace chat if delayed submission is enabled #52183

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4f1e036
separated isArchivedExpenseReport
FitseTLT Nov 7, 2024
e479b03
hide approve and submit button for archived expense reports
FitseTLT Nov 7, 2024
80079f1
removed isArchived conditions
FitseTLT Nov 11, 2024
6baee2f
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Nov 13, 2024
d1e30bb
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Nov 13, 2024
6e97db2
removed unnecessary code
FitseTLT Nov 13, 2024
58258ed
remove unnecessary condition
FitseTLT Nov 13, 2024
e0da388
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Nov 14, 2024
1f48cb9
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Nov 20, 2024
a79e87b
updated isArchived conditions
FitseTLT Nov 21, 2024
367f750
changed function name
FitseTLT Nov 21, 2024
10afdfb
resolved conflicts
FitseTLT Nov 25, 2024
4a8865d
minor fix
FitseTLT Nov 25, 2024
76b27d1
updated based on comments
FitseTLT Nov 25, 2024
9e36537
updated hold cases
FitseTLT Nov 25, 2024
eba01f4
fix lint
FitseTLT Nov 25, 2024
f9b33a5
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Nov 26, 2024
76a7157
additional changes
FitseTLT Nov 27, 2024
1241ae3
allowed actions for archived expense requests
FitseTLT Nov 27, 2024
dc76f27
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Nov 27, 2024
3cc72aa
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Dec 4, 2024
7e8e192
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Dec 4, 2024
6983f3a
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Dec 9, 2024
d68c6c8
made more changes
FitseTLT Dec 9, 2024
acfa644
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Jan 6, 2025
f3a150a
minor fix
FitseTLT Jan 6, 2025
2ccb1aa
minor fix
FitseTLT Jan 6, 2025
3d47bca
fix lint
FitseTLT Jan 6, 2025
79ecf64
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Jan 6, 2025
1d6f146
lint fix
FitseTLT Jan 6, 2025
b28ce3c
lint fix
FitseTLT Jan 6, 2025
33a9c1a
minor fix
FitseTLT Jan 6, 2025
2f69e3d
lint fix
FitseTLT Jan 6, 2025
0de9910
fix lint
FitseTLT Jan 6, 2025
7ea58c7
lint fix
FitseTLT Jan 6, 2025
6f9093a
minor fix
FitseTLT Jan 6, 2025
02e102a
lint fix
FitseTLT Jan 6, 2025
949f169
minor fix
FitseTLT Jan 6, 2025
466da88
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Jan 8, 2025
997781a
minor fix
FitseTLT Jan 8, 2025
c239018
fix getLastMessageTextForReport
FitseTLT Jan 8, 2025
800996e
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Jan 9, 2025
4238c73
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Jan 13, 2025
6e688e1
Merge branch 'main' into fix-expense-report-for-archived-workspaces
FitseTLT Jan 13, 2025
7b22d11
minor fix
FitseTLT Jan 13, 2025
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
3 changes: 3 additions & 0 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? '');
const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction);
const isArchivedReport = ReportUtils.isArchivedRoomWithID(moneyRequestReport?.reportID);
const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(moneyRequestReport);
const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID ?? '-1'}`, {selector: ReportUtils.getArchiveReason});

const getCanIOUBePaid = useCallback(
Expand All @@ -143,6 +144,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea

const shouldShowSubmitButton =
!!moneyRequestReport &&
!isArchivedReport &&
!isArchivedExpenseReport &&
isDraft &&
reimbursableSpend !== 0 &&
!hasAllPendingRTERViolations &&
Expand Down
5 changes: 4 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ function ReportPreview({
formattedMerchant = null;
}

const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport);
const isArchivedReport = ReportUtils.isArchivedRoomWithID(iouReportID);
const currentUserAccountID = getCurrentUserAccountID();
const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
const shouldShowSubmitButton =
isOpenExpenseReport &&
!isArchivedExpenseReport &&
!isArchivedReport &&
reimbursableSpend !== 0 &&
!showRTERViolationMessage &&
!shouldShowBrokenConnectionViolation &&
Expand Down Expand Up @@ -358,7 +362,6 @@ function ReportPreview({
const shouldShowPendingSubtitle = numberOfPendingRequests === 1 && numberOfRequests === 1;

const isPayAtEndExpense = ReportUtils.isPayAtEndExpenseReport(iouReportID, allTransactions);
const isArchivedReport = ReportUtils.isArchivedRoomWithID(iouReportID);
const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, {selector: ReportUtils.getArchiveReason});

const getPendingMessageProps: () => PendingMessageProps = () => {
Expand Down
12 changes: 10 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,14 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>): boolean
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isArchivedRoom(report: OnyxInputOrEntry<Report>, reportNameValuePairs?: OnyxInputOrEntry<ReportNameValuePairs>): boolean {
return !!report?.private_isArchived;
return !isExpenseReport(report) && !!report?.private_isArchived;
}

/**
* Whether the provided report is an archived expense report
*/
function isArchivedExpenseReport(report: OnyxInputOrEntry<Report>): boolean {
return isExpenseReport(report) && !!report?.private_isArchived;
}

/**
Expand Down Expand Up @@ -6998,7 +7005,7 @@ function isGroupChatAdmin(report: OnyxEntry<Report>, accountID: number) {
*/
function getMoneyRequestOptions(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>, reportParticipants: number[], filterDeprecatedTypes = false): IOUType[] {
// In any thread or task report, we do not allow any new expenses yet
if (isChatThread(report) || isTaskReport(report) || isInvoiceReport(report) || isSystemChat(report)) {
if (isChatThread(report) || isTaskReport(report) || isInvoiceReport(report) || isSystemChat(report) || isArchivedExpenseReport(report)) {
return [];
}

Expand Down Expand Up @@ -8587,6 +8594,7 @@ export {
isAllowedToSubmitDraftExpenseReport,
isAnnounceRoom,
isArchivedRoom,
isArchivedExpenseReport,
isArchivedRoomWithID,
isClosedReport,
isCanceledTaskReport,
Expand Down
4 changes: 3 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7055,6 +7055,8 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry<OnyxTypes.Report>,
const iouSettled = ReportUtils.isSettled(iouReport?.reportID);
const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID);
const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs);
const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport);

let isTransactionBeingScanned = false;
const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport?.reportID);
for (const transaction of reportTransactions) {
Expand All @@ -7067,7 +7069,7 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry<OnyxTypes.Report>,
}
}

return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isTransactionBeingScanned;
return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isArchivedExpenseReport && !isTransactionBeingScanned;
}

function canIOUBePaid(
Expand Down
Loading