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 42 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
10 changes: 5 additions & 5 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ const ROUTES = {
},
REPORT_WITH_ID_DETAILS: {
route: 'r/:reportID/details',
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details`, backTo),
getRoute: (reportID: string | undefined, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details`, backTo),
},
REPORT_WITH_ID_DETAILS_EXPORT: {
route: 'r/:reportID/details/export/:connectionName',
Expand Down Expand Up @@ -398,7 +398,7 @@ const ROUTES = {
},
REPORT_DESCRIPTION: {
route: 'r/:reportID/description',
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/description` as const, backTo),
getRoute: (reportID: string | undefined, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/description` as const, backTo),
},
TASK_ASSIGNEE: {
route: 'r/:reportID/assignee',
Expand Down Expand Up @@ -895,7 +895,7 @@ const ROUTES = {
},
WORKSPACE_PROFILE_DESCRIPTION: {
route: 'settings/workspaces/:policyID/profile/description',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/description` as const,
getRoute: (policyID: string | undefined) => `settings/workspaces/${policyID}/profile/description` as const,
},
WORKSPACE_PROFILE_SHARE: {
route: 'settings/workspaces/:policyID/profile/share',
Expand Down Expand Up @@ -1221,7 +1221,7 @@ const ROUTES = {
},
WORKSPACE_COMPANY_CARDS: {
route: 'settings/workspaces/:policyID/company-cards',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards` as const,
getRoute: (policyID: string | undefined) => `settings/workspaces/${policyID}/company-cards` as const,
},
WORKSPACE_COMPANY_CARDS_ADD_NEW: {
route: 'settings/workspaces/:policyID/company-cards/add-card-feed',
Expand Down Expand Up @@ -1473,7 +1473,7 @@ const ROUTES = {

TRANSACTION_DUPLICATE_REVIEW_PAGE: {
route: 'r/:threadReportID/duplicates/review',
getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo),
getRoute: (threadReportID: string | undefined, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo),
},
TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE: {
route: 'r/:threadReportID/duplicates/review/merchant',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
if (isDisabled) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs));
}}
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
Expand Down
6 changes: 3 additions & 3 deletions src/components/BrokenConnectionDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TextLink from './TextLink';

type BrokenConnectionDescriptionProps = {
/** Transaction id of the corresponding report */
transactionID: string;
transactionID: string | undefined;

/** Current report */
report: OnyxEntry<Report>;
Expand All @@ -40,13 +40,13 @@ function BrokenConnectionDescription({transactionID, policy, report}: BrokenConn
return translate('violations.brokenConnection530Error');
}

if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID ?? '')) {
if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID)) {
return (
<>
{`${translate('violations.adminBrokenConnectionError')}`}
<TextLink
style={[styles.textLabelSupporting, styles.link]}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id ?? '-1'))}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id))}
>{`${translate('workspace.common.companyCards')}`}</TextLink>
.
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ function ImageRenderer({tnode}: ImageRendererProps) {
if (isDisabled) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs),
);
}}
shouldUseHapticsOnLongPress
accessibilityRole={CONST.ROLE.BUTTON}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
if (isDisabled) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs));
}}
onPress={(event) => {
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
if (isDisabled) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs));
}}
shouldUseHapticsOnLongPress
role={CONST.ROLE.PRESENTATION}
Expand Down
45 changes: 24 additions & 21 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type MoneyReportHeaderProps = {

/** The reportID of the transaction thread report associated with this current report, if any */
// eslint-disable-next-line react/no-unused-prop-types
transactionThreadReportID?: string | null;
transactionThreadReportID: string | undefined;

/** Method to trigger when pressing close button of the header */
onBackButtonPress: () => void;
Expand All @@ -67,8 +67,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout();
const route = useRoute();
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID ?? '-1'}`);
const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID ?? '-1'}`);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`);
const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID}`);
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`);
const [session] = useOnyx(ONYXKEYS.SESSION);
const requestParentReportAction = useMemo(() => {
Expand All @@ -83,7 +83,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const transaction =
transactions?.[
`${ONYXKEYS.COLLECTION.TRANSACTION}${
ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? -1 : -1
ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) && ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID
}`
] ?? undefined;

Expand All @@ -96,7 +96,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(moneyRequestReport);
const isOnHold = TransactionUtils.isOnHold(transaction);
const isDeletedParentAction = !!requestParentReportAction && ReportActionsUtils.isDeletedAction(requestParentReportAction);
const isDuplicate = TransactionUtils.isDuplicate(transaction?.transactionID ?? '');
const isDuplicate = TransactionUtils.isDuplicate(transaction?.transactionID);

// Only the requestor can delete the request, admins can only edit it.
const isActionOwner =
Expand All @@ -115,12 +115,12 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const hasScanningReceipt = ReportUtils.getTransactionsWithReceipts(moneyRequestReport?.reportID).some((t) => TransactionUtils.isReceiptBeingScanned(t));
const hasOnlyPendingTransactions = allTransactions.length > 0 && allTransactions.every((t) => TransactionUtils.isExpensifyCardTransaction(t) && TransactionUtils.isPending(t));
const transactionIDs = allTransactions.map((t) => t.transactionID);
const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '-1']);
const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID ?? '-1', moneyRequestReport, policy);
const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? '');
const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID]);
const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID, moneyRequestReport, policy);
const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID);
const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction);
const isArchivedReport = ReportUtils.isArchivedRoomWithID(moneyRequestReport?.reportID);
const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID ?? '-1'}`, {selector: ReportUtils.getArchiveReason});
const isArchivedReport = ReportUtils.isArchivedReport(moneyRequestReport);
const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID}`, {selector: ReportUtils.getArchiveReason});

const getCanIOUBePaid = useCallback(
(onlyShowPayElsewhere = false) => IOU.canIOUBePaid(moneyRequestReport, chatReport, policy, transaction ? [transaction] : undefined, onlyShowPayElsewhere),
Expand All @@ -131,8 +131,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const onlyShowPayElsewhere = useMemo(() => !canIOUBePaid && getCanIOUBePaid(true), [canIOUBePaid, getCanIOUBePaid]);

const shouldShowMarkAsCashButton =
hasAllPendingRTERViolations ||
(shouldShowBrokenConnectionViolation && (!PolicyUtils.isPolicyAdmin(policy) || ReportUtils.isCurrentUserSubmitter(moneyRequestReport?.reportID ?? '')));
hasAllPendingRTERViolations || (shouldShowBrokenConnectionViolation && (!PolicyUtils.isPolicyAdmin(policy) || ReportUtils.isCurrentUserSubmitter(moneyRequestReport?.reportID)));

const shouldShowPayButton = canIOUBePaid || onlyShowPayElsewhere;

Expand All @@ -145,6 +144,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea

const shouldShowSubmitButton =
!!moneyRequestReport &&
!isArchivedReport &&
isDraft &&
reimbursableSpend !== 0 &&
!hasAllPendingRTERViolations &&
Expand Down Expand Up @@ -215,10 +215,10 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const deleteTransaction = useCallback(() => {
if (requestParentReportAction) {
const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction)
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '-1'
: '-1';
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID
: undefined;
if (ReportActionsUtils.isTrackExpenseAction(requestParentReportAction)) {
navigateBackToAfterDelete.current = IOU.deleteTrackExpense(moneyRequestReport?.reportID ?? '-1', iouTransactionID, requestParentReportAction, true);
navigateBackToAfterDelete.current = IOU.deleteTrackExpense(moneyRequestReport?.reportID, iouTransactionID, requestParentReportAction, true);
} else {
navigateBackToAfterDelete.current = IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction, true);
}
Expand All @@ -232,10 +232,13 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
return;
}
const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction)
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '-1'
: '-1';
const reportID = transactionThreadReport?.reportID ?? '-1';
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID
: undefined;
const reportID = transactionThreadReport?.reportID;

if (!iouTransactionID || !reportID) {
return;
}
TransactionActions.markAsCash(iouTransactionID, reportID);
}, [requestParentReportAction, transactionThreadReport?.reportID]);

Expand Down Expand Up @@ -265,7 +268,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
icon: getStatusIcon(Expensicons.Hourglass),
description: (
<BrokenConnectionDescription
transactionID={transaction?.transactionID ?? '-1'}
transactionID={transaction?.transactionID}
report={moneyRequestReport}
policy={policy}
/>
Expand Down Expand Up @@ -354,7 +357,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
text={translate('iou.reviewDuplicates')}
style={styles.p0}
onPress={() => {
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID ?? '', Navigation.getReportRHPActiveRoute()));
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID, Navigation.getReportRHPActiveRoute()));
}}
/>
</View>
Expand Down Expand Up @@ -422,7 +425,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
text={translate('iou.reviewDuplicates')}
style={[styles.flex1, styles.pr0]}
onPress={() => {
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID ?? '', Navigation.getReportRHPActiveRoute()));
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID, Navigation.getReportRHPActiveRoute()));
}}
/>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ function ReportPreview({
formattedMerchant = null;
}

const isArchivedReport = ReportUtils.isArchivedReport(iouReport);
const currentUserAccountID = getCurrentUserAccountID();
const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
const shouldShowSubmitButton =
isOpenExpenseReport &&
!isArchivedReport &&
reimbursableSpend !== 0 &&
!showRTERViolationMessage &&
!shouldShowBrokenConnectionViolation &&
Expand Down Expand Up @@ -383,7 +385,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
Loading
Loading