Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const hasDraftComment = isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);

const canUserPerformWrite = canUserPerformWriteAction(item);
const isReportArchived = !!itemReportNameValuePairs?.private_isArchived;
const canUserPerformWrite = canUserPerformWriteAction(item, isReportArchived);
const sortedReportActions = getSortedReportActionsForDisplay(itemReportActions, canUserPerformWrite);
const lastReportAction = sortedReportActions.at(0);

Expand Down Expand Up @@ -247,6 +248,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
isReportsSplitNavigatorLast={isReportsSplitNavigatorLast}
isScreenFocused={isScreenFocused}
localeCompare={localeCompare}
isReportArchived={isReportArchived}
/>
);
},
Expand Down
5 changes: 3 additions & 2 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function OptionRowLHNData({
transactionViolations,
lastMessageTextFromReport,
localeCompare,
isReportArchived = false,
...propsToForward
}: OptionRowLHNDataProps) {
const reportID = propsToForward.reportID;
Expand All @@ -48,15 +49,15 @@ function OptionRowLHNData({
return undefined;
}

const canUserPerformWriteAction = canUserPerformWriteActionUtil(fullReport);
const canUserPerformWriteAction = canUserPerformWriteActionUtil(fullReport, isReportArchived);
const actionsArray = getSortedReportActions(Object.values(reportActions));

const reportActionsForDisplay = actionsArray.filter(
(reportAction) => shouldReportActionBeVisibleAsLastAction(reportAction, canUserPerformWriteAction) && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED,
);

return reportActionsForDisplay.at(-1);
}, [reportActions, fullReport]);
}, [reportActions, fullReport, isReportArchived]);

const card = useGetExpensifyCardFromReportAction({reportAction: lastAction, policyID: fullReport?.policyID});
const optionItem = useMemo(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ type OptionRowLHNDataProps = {

/** Function to compare locale strings */
localeCompare: LocaleContextProps['localeCompare'];

/** Whether the report is archived */
isReportArchived: boolean;
};

type OptionRowLHNProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import useNetworkWithOfflineStatus from '@hooks/useNetworkWithOfflineStatus';
import useOnyx from '@hooks/useOnyx';
import usePrevious from '@hooks/usePrevious';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useReportScrollManager from '@hooks/useReportScrollManager';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSelectedTransactionsActions from '@hooks/useSelectedTransactionsActions';
Expand Down Expand Up @@ -156,7 +157,8 @@
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true});
const [currentUserAccountID] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false, selector: (session) => session?.accountID});

const canPerformWriteAction = canUserPerformWriteAction(report);
const isReportArchived = useReportIsArchived(reportID);
const canPerformWriteAction = canUserPerformWriteAction(report, isReportArchived);

const {shouldUseNarrowLayout} = useResponsiveLayout();

Expand Down Expand Up @@ -539,11 +541,12 @@
personalDetails={personalDetails}
userBillingFundID={userBillingFundID}
emojiReactions={actionEmojiReactions}
isReportArchived={isReportArchived}
draftMessage={matchingDraftMessageString}
/>
);
},
[

Check warning on line 549 in src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has a missing dependency: 'isReportArchived'. Either include it or remove the dependency array

Check warning on line 549 in src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has a missing dependency: 'isReportArchived'. Either include it or remove the dependency array
visibleReportActions,
reportActions,
parentReportAction,
Expand Down
4 changes: 3 additions & 1 deletion src/components/ParentNavigationSubtitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {StyleProp, TextStyle} from 'react-native';
import useHover from '@hooks/useHover';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useRootNavigationState from '@hooks/useRootNavigationState';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
Expand Down Expand Up @@ -57,7 +58,8 @@ function ParentNavigationSubtitle({
const {workspaceName, reportName} = parentNavigationSubtitleData;
const {translate} = useLocalize();
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`, {canBeMissing: false});
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report);
const isReportArchived = useReportIsArchived(report?.reportID);
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report, isReportArchived);
const isReportInRHP = currentRoute.name === SCREENS.SEARCH.REPORT_RHP;
const currentFullScreenRoute = useRootNavigationState((state) => state?.routes?.findLast((route) => isFullScreenName(route.name)));

Expand Down
21 changes: 11 additions & 10 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,20 @@ function MoneyRequestView({

// Flags for allowing or disallowing editing an expense
// Used for non-restricted fields such as: description, category, tag, billable, etc...
const canUserPerformWriteAction = !!canUserPerformWriteActionReportUtils(report) && !readonly;
const canEdit = isMoneyRequestAction(parentReportAction) && canEditMoneyRequest(parentReportAction, transaction, isChatReportArchived) && canUserPerformWriteAction;
const isReportArchived = useReportIsArchived(report?.reportID);
const isEditable = !!canUserPerformWriteActionReportUtils(report, isReportArchived) && !readonly;
const canEdit = isMoneyRequestAction(parentReportAction) && canEditMoneyRequest(parentReportAction, transaction, isChatReportArchived) && isEditable;

const canEditTaxFields = canEdit && !isDistanceRequest;
const canEditAmount = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.AMOUNT, undefined, isChatReportArchived);
const canEditMerchant = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.MERCHANT, undefined, isChatReportArchived);
const canEditDate = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DATE, undefined, isChatReportArchived);
const canEditReceipt = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT, undefined, isChatReportArchived);
const canEditDistance = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE, undefined, isChatReportArchived);
const canEditDistanceRate = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE_RATE, undefined, isChatReportArchived);
const canEditAmount = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.AMOUNT, undefined, isChatReportArchived);
const canEditMerchant = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.MERCHANT, undefined, isChatReportArchived);
const canEditDate = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DATE, undefined, isChatReportArchived);
const canEditReceipt = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT, undefined, isChatReportArchived);
const canEditDistance = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE, undefined, isChatReportArchived);
const canEditDistanceRate = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE_RATE, undefined, isChatReportArchived);
const canEditReport = useMemo(
() => canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REPORT, undefined, isChatReportArchived, outstandingReportsByPolicyID),
[canUserPerformWriteAction, parentReportAction, isChatReportArchived, outstandingReportsByPolicyID],
() => isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REPORT, undefined, isChatReportArchived, outstandingReportsByPolicyID),
[isEditable, parentReportAction, isChatReportArchived, outstandingReportsByPolicyID],
);

// A flag for verifying that the current report is a sub-report of a expense chat
Expand Down
5 changes: 3 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@
const parsedReportActionMessageCache: Record<string, string> = {};

let conciergeReportID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 902 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportID = value;
Expand All @@ -907,7 +907,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 910 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -925,7 +925,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 928 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (currentUserAccountID) {
Expand All @@ -937,14 +937,14 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 940 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 947 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand All @@ -952,7 +952,7 @@

let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 955 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -993,14 +993,14 @@
});

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({

Check warning on line 996 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

let allTransactions: OnyxCollection<Transaction> = {};
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1003 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1026,7 +1026,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1029 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -9010,7 +9010,7 @@
}
}

function canUserPerformWriteAction(report: OnyxEntry<Report>) {
function canUserPerformWriteAction(report: OnyxEntry<Report>, isReportArchived?: boolean) {
Comment thread
thelullabyy marked this conversation as resolved.
Comment thread
thelullabyy marked this conversation as resolved.
const reportErrors = getCreationReportErrors(report);

// If the expense report is marked for deletion, let us prevent any further write action.
Expand All @@ -9021,8 +9021,9 @@
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
const reportNameValuePairs = getReportNameValuePairs(report?.reportID);
Comment thread
thelullabyy marked this conversation as resolved.

return (
!isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived) &&
!isArchivedNonExpenseReport(report, isReportArchived ?? !!reportNameValuePairs?.private_isArchived) &&
isEmptyObject(reportErrors) &&
report &&
isAllowedToComment(report) &&
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Debug/Report/DebugReportActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function DebugReportActions({reportID}: DebugReportActionsProps) {
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true});
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, {canBeMissing: true});
const isReportArchived = useReportIsArchived(reportID);
const ifUserCanPerformWriteAction = canUserPerformWriteAction(report);
const ifUserCanPerformWriteAction = canUserPerformWriteAction(report, isReportArchived);
const [sortedAllReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
canEvict: false,
selector: (allReportActions) => getSortedReportActionsForDisplay(allReportActions, ifUserCanPerformWriteAction, true),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
account?.guideDetails?.email !== CONST.EMAIL.CONCIERGE &&
!!account?.guideDetails?.calendarLink &&
isAdminRoom(report) &&
!!canUserPerformWriteAction(report) &&
!!canUserPerformWriteAction(report, isReportArchived) &&
!isChatThread &&
introSelected?.companySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO;

Expand Down
6 changes: 4 additions & 2 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import useOnyx from '@hooks/useOnyx';
import usePaginatedReportActions from '@hooks/usePaginatedReportActions';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';
Expand Down Expand Up @@ -402,9 +403,10 @@ function ReportScreen({route, navigation}: ReportScreenProps) {

const {isEditingDisabled, isCurrentReportLoadedFromOnyx} = useIsReportReadyToDisplay(report, reportIDFromRoute);

const isReportArchived = useReportIsArchived(report?.reportID);
const isLinkedActionDeleted = useMemo(
() => !!linkedAction && !shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID, canUserPerformWriteAction(report)),
[linkedAction, report],
() => !!linkedAction && !shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID, canUserPerformWriteAction(report, isReportArchived)),
[linkedAction, report, isReportArchived],
);

const prevIsLinkedActionDeleted = usePrevious(linkedAction ? isLinkedActionDeleted : undefined);
Expand Down
6 changes: 5 additions & 1 deletion src/pages/home/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ type ReportActionItemParentActionProps = {

/** User billing fund ID */
userBillingFundID: number | undefined;

/** Whether the report is archived */
isReportArchived: boolean;
};

function ReportActionItemParentAction({
Expand All @@ -106,6 +109,7 @@ function ReportActionItemParentAction({
allEmojiReactions,
linkedTransactionRouteError,
userBillingFundID,
isReportArchived = false,
}: ReportActionItemParentActionProps) {
const styles = useThemeStyles();
const ancestorIDs = useRef(getAllAncestorReportActionIDs(report));
Expand Down Expand Up @@ -167,7 +171,7 @@ function ReportActionItemParentAction({
{/* eslint-disable-next-line react-compiler/react-compiler */}
{allAncestors.map((ancestor) => {
const ancestorReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${ancestor.report.reportID}`];
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(ancestorReport);
const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(ancestorReport, isReportArchived);
const shouldDisplayThreadDivider = !isTripPreview(ancestor.reportAction);
const reportNameValuePair =
ancestorReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${ancestorReports.current?.[ancestor?.report?.reportID]?.reportID}`];
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ function ReportActionsList({
emojiReactions={actionEmojiReactions}
allDraftMessages={draftMessage}
allEmojiReactions={emojiReactions}
isReportArchived={isReportArchived}
linkedTransactionRouteError={actionLinkedTransactionRouteError}
userBillingFundID={userBillingFundID}
/>
Expand Down Expand Up @@ -690,6 +691,7 @@ function ReportActionsList({
isUserValidated,
personalDetailsList,
userBillingFundID,
isReportArchived,
],
);

Expand All @@ -699,7 +701,7 @@ function ReportActionsList({
() => [shouldUseNarrowLayout ? unreadMarkerReportActionID : undefined, isArchivedNonExpenseReport(report, isReportArchived)],
[unreadMarkerReportActionID, shouldUseNarrowLayout, report, isReportArchived],
);
const hideComposer = !canUserPerformWriteAction(report);
const hideComposer = !canUserPerformWriteAction(report, isReportArchived);
const shouldShowReportRecipientLocalTime = canShowReportRecipientLocalTime(personalDetailsList, report, currentUserPersonalDetails.accountID) && !isComposerFullSize;
const canShowHeader = isOffline || hasHeaderRendered.current;

Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/report/ReportActionsListItemRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ type ReportActionsListItemRendererProps = {

/** All emoji reactions collection */
allEmojiReactions?: OnyxCollection<ReportActionReactions>;

/** Whether the report is archived */
isReportArchived: boolean;
};

function ReportActionsListItemRenderer({
Expand Down Expand Up @@ -123,6 +126,7 @@ function ReportActionsListItemRenderer({
personalDetails,
allDraftMessages,
allEmojiReactions,
isReportArchived = false,
}: ReportActionsListItemRendererProps) {
const originalMessage = useMemo(() => getOriginalMessage(reportAction), [reportAction]);

Expand Down Expand Up @@ -219,6 +223,7 @@ function ReportActionsListItemRenderer({
allEmojiReactions={allEmojiReactions}
linkedTransactionRouteError={linkedTransactionRouteError}
userBillingFundID={userBillingFundID}
isReportArchived={isReportArchived}
/>
);
}
Expand Down
6 changes: 4 additions & 2 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useLoadReportActions from '@hooks/useLoadReportActions';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePrevious from '@hooks/usePrevious';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';
import {updateLoadingInitialReportAction} from '@libs/actions/Report';
Expand Down Expand Up @@ -77,8 +78,9 @@ function ReportActionsView({
}: ReportActionsViewProps) {
useCopySelectionHelper();
const route = useRoute<PlatformStackRouteProp<ReportsSplitNavigatorParamList, typeof SCREENS.REPORT>>();
const isReportArchived = useReportIsArchived(report?.reportID);
const [transactionThreadReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`, {
selector: (reportActions: OnyxEntry<OnyxTypes.ReportActions>) => getSortedReportActionsForDisplay(reportActions, canUserPerformWriteAction(report), true),
selector: (reportActions: OnyxEntry<OnyxTypes.ReportActions>) => getSortedReportActionsForDisplay(reportActions, canUserPerformWriteAction(report, isReportArchived), true),
canBeMissing: true,
});
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true});
Expand Down Expand Up @@ -194,7 +196,7 @@ function ReportActionsView({
[allReportActions, transactionThreadReportActions, transactionThreadReport?.parentReportActionID],
);

const canPerformWriteAction = canUserPerformWriteAction(report);
const canPerformWriteAction = canUserPerformWriteAction(report, isReportArchived);
const visibleReportActions = useMemo(
() =>
reportActions.filter(
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function ReportFooter({

// If a user just signed in and is viewing a public report, optimistically show the composer while loading the report, since they will have write access when the response comes back.
const shouldShowComposerOptimistically = !isAnonymousUser && isPublicRoom(report) && !!reportMetadata?.isLoadingInitialReportActions;
const canPerformWriteAction = canUserPerformWriteAction(report) ?? shouldShowComposerOptimistically;
const canPerformWriteAction = canUserPerformWriteAction(report, isReportArchived) ?? shouldShowComposerOptimistically;
const shouldHideComposer = !canPerformWriteAction || isBlockedFromChat;
const canWriteInReport = canWriteInReportUtil(report);
const isSystemChat = isSystemChatUtil(report);
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/report/ThreadDivider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {PressableWithoutFeedback} from '@components/Pressable';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -28,6 +29,7 @@ function ThreadDivider({ancestor, isLinkDisabled = false}: ThreadDividerProps) {
const {translate} = useLocalize();
const {isInNarrowPaneModal} = useResponsiveLayout();
const {isOffline} = useNetwork();
const isReportArchived = useReportIsArchived(ancestor.report.reportID);

return (
<View
Expand All @@ -46,7 +48,7 @@ function ThreadDivider({ancestor, isLinkDisabled = false}: ThreadDividerProps) {
</>
) : (
<PressableWithoutFeedback
onPress={() => navigateToLinkedReportAction(ancestor, isInNarrowPaneModal, canUserPerformWriteAction(ancestor.report), isOffline)}
onPress={() => navigateToLinkedReportAction(ancestor, isInNarrowPaneModal, canUserPerformWriteAction(ancestor.report, isReportArchived), isOffline)}
accessibilityLabel={translate('threads.thread')}
role={CONST.ROLE.BUTTON}
style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}
Expand Down
Loading
Loading