Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
50c127e
refactor
Tony-MK Jun 12, 2025
17bd312
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 13, 2025
cd5f5ea
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 13, 2025
9c419b6
refactoring canEditRoomVisibility params
Tony-MK Jun 13, 2025
24317b0
comment
Tony-MK Jun 13, 2025
79b3df5
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 15, 2025
8cd2711
Merge branch 'fix/64013' of https://github.com/Tony-MK/Expensify-App …
Tony-MK Jun 15, 2025
d864fb8
lint
Tony-MK Jun 15, 2025
42b789b
prettier
Tony-MK Jun 15, 2025
67a5f9d
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 17, 2025
b0db226
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 18, 2025
2cc7a22
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 20, 2025
dda589d
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 20, 2025
a15b25d
changed isArchivedNonExpenseReport second param to accept private_isA…
Tony-MK Jun 20, 2025
646d70f
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 20, 2025
592fa8a
typecheck
Tony-MK Jun 20, 2025
0815356
lint errors
Tony-MK Jun 20, 2025
19cb2ae
prettier
Tony-MK Jun 20, 2025
aa78a7d
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 23, 2025
d16b6ea
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 23, 2025
40ebb70
Merge branch 'Expensify:main' into fix/64013
Tony-MK Jun 23, 2025
b286f5e
refactoring
Tony-MK Jun 24, 2025
36801bf
Merge branch 'main' into fix/64013
Tony-MK Jun 24, 2025
79ca880
defaulting to false for isArchivedNonExpenseReport
Tony-MK Jun 24, 2025
7023bc4
lint
Tony-MK Jun 24, 2025
87aefdf
prettier
Tony-MK Jun 24, 2025
5a220f5
revert
Tony-MK Jun 26, 2025
5e2a5d5
lint
Tony-MK Jun 26, 2025
9b3219a
lint
Tony-MK Jun 26, 2025
2313b8d
removing async
Tony-MK Jun 26, 2025
cfb3d7b
Merge branch 'main' of https://github.com/Expensify/App into fix/64013
Tony-MK Jun 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {ShowContextMenuContext, showContextMenuForReport} from '@components/Show
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import * as Browser from '@libs/Browser';
import {isMobileSafari} from '@libs/Browser';
import fileDownload from '@libs/fileDownload';
import * as ReportUtils from '@libs/ReportUtils';
import * as Download from '@userActions/Download';
import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
import {setDownload} from '@userActions/Download';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type AnchorForAttachmentsOnlyProps from './types';
Expand All @@ -26,7 +26,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source);
const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];

const [download] = useOnyx(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`);
const [download] = useOnyx(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`, {canBeMissing: true});

const {isOffline} = useNetwork();
const styles = useThemeStyles();
Expand All @@ -42,16 +42,23 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
if (isDownloading || isOffline || !sourceID) {
return;
}
Download.setDownload(sourceID, true);
fileDownload(sourceURLWithAuth, displayName, '', Browser.isMobileSafari()).then(() => Download.setDownload(sourceID, false));
setDownload(sourceID, true);
fileDownload(sourceURLWithAuth, displayName, '', isMobileSafari()).then(() => setDownload(sourceID, false));
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
onLongPress={(event) => {
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs));
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived),
Comment thread
Tony-MK marked this conversation as resolved.
);
}}
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ function ImageRenderer({tnode}: ImageRendererProps) {
return;
}
return onShowContextMenu(() =>
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, reportNameValuePairs)),
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived),
),
);
}}
isNested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
return;
}
return onShowContextMenu(() =>
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, reportNameValuePairs)),
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived),
),
);
}}
onPress={(event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
if (isDisabled || !shouldDisplayContextMenu) {
return;
}
return showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, reportNameValuePairs));
return showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived),
);
});
}}
shouldUseHapticsOnLongPress
Expand Down
4 changes: 1 addition & 3 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined}`, {canBeMissing: false});
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID || undefined}`, {canBeMissing: true});
const isArchivedRoom = isArchivedNonExpenseReport(report, reportNameValuePairs);
const isChatRoom = isChatRoomReportUtils(report);
const isSelfDM = isSelfDMReportUtils(report);
const isInvoiceRoom = isInvoiceRoomReportUtils(report);
Expand All @@ -64,6 +61,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
const displayNamesWithTooltips = getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
const isReportArchived = useReportIsArchived(report?.reportID);
const welcomeMessage = SidebarUtils.getWelcomeMessage(report, policy, isReportArchived);
const isArchivedRoom = isArchivedNonExpenseReport(report, isReportArchived);
const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs);
const policyName = getPolicyName({report});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel, isDele
return;
}
onShowContextMenu(() => {
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, reportNameValuePairs));
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived),
);
});
}}
shouldUseHapticsOnLongPress
Expand Down
4 changes: 2 additions & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ function getLastMessageTextForReport(
const lastOriginalReportAction = reportID ? lastReportActions[reportID] : undefined;
let lastMessageTextFromReport = '';

if (isArchivedNonExpenseReport(report, reportNameValuePairs)) {
if (isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived)) {
const archiveReason =
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
(isClosedAction(lastOriginalReportAction) && getOriginalMessage(lastOriginalReportAction)?.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT;
Expand Down Expand Up @@ -977,7 +977,7 @@ function createOption(accountIDs: number[], personalDetails: OnyxInputOrEntry<Pe
lastAction &&
lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW &&
lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU &&
!isArchivedNonExpenseReport(report, reportNameValuePairs) &&
!isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived) &&
shouldShowLastActorDisplayName(report, lastActorDetails, lastAction);
if (shouldDisplayLastActorName && lastActorDisplayName && lastMessageTextFromReport) {
lastMessageText = `${lastActorDisplayName}: ${lastMessageTextFromReport}`;
Expand Down
43 changes: 27 additions & 16 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2047,8 +2047,8 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>, transact
* Whether the provided report is an archived room
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function isArchivedNonExpenseReport(report: OnyxInputOrEntry<Report> | SearchReport, reportNameValuePairs?: OnyxInputOrEntry<ReportNameValuePairs>): boolean {
return !(isExpenseReport(report) || isExpenseRequest(report)) && !!reportNameValuePairs?.private_isArchived;
function isArchivedNonExpenseReport(report: OnyxInputOrEntry<Report> | SearchReport, isReportArchived = false): boolean {
return isReportArchived && !(isExpenseReport(report) || isExpenseRequest(report));
}

/**
Expand Down Expand Up @@ -3273,7 +3273,12 @@ function getIcons(
const reportNameValuePairs = allReportNameValuePair?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`];
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || (isArchivedNonExpenseReport(report, reportNameValuePairs) && !chatIncludesConcierge(report))) {
if (
isAdminRoom(report) ||
isAnnounceRoom(report) ||
isChatRoom(report) ||
(isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived) && !chatIncludesConcierge(report))
) {
return getIconsForPolicyRoom(report, personalDetails, policy, invoiceReceiverPolicy);
}
if (isPolicyExpenseChat(report)) {
Expand Down Expand Up @@ -3748,7 +3753,7 @@ function getPolicyExpenseChatName({
// of the account which was merged into the current user's account. Use the name of the policy as the name of the report.
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) {
if (isArchivedNonExpenseReport(report, !!getReportNameValuePairs(report?.reportID)?.private_isArchived)) {
const lastAction = getLastVisibleActionReportActionsUtils(report?.reportID);
const archiveReason = isClosedAction(lastAction) ? getOriginalMessage(lastAction)?.reason : CONST.REPORT.ARCHIVE_REASON.DEFAULT;
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED && policyExpenseChatRole !== CONST.POLICY.ROLE.ADMIN) {
Expand Down Expand Up @@ -5054,7 +5059,7 @@ function getReportNameInternal({
const parentReportActionMessage = getReportActionMessageReportUtils(parentReportAction);
const isArchivedNonExpense = isArchivedNonExpenseReport(
report,
reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)}`],
!!reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)}`]?.private_isArchived,
);

if (
Expand Down Expand Up @@ -5387,7 +5392,7 @@ function getParentNavigationSubtitle(report: OnyxEntry<Report>, invoiceReceiverP

// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
if (isArchivedNonExpenseReport(parentReport, getReportNameValuePairs(parentReport?.reportID))) {
if (isArchivedNonExpenseReport(parentReport, !!getReportNameValuePairs(parentReport?.reportID)?.private_isArchived)) {
reportName += ` (${translateLocal('common.archived')})`;
}

Expand Down Expand Up @@ -7882,7 +7887,7 @@ function canSeeDefaultRoom(report: OnyxEntry<Report>, betas: OnyxEntry<Beta[]>):
// Include archived rooms
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) {
if (isArchivedNonExpenseReport(report, !!getReportNameValuePairs(report?.reportID)?.private_isArchived)) {
return true;
}

Expand Down Expand Up @@ -8261,7 +8266,7 @@ function reasonForReportToBeInOptionList({
// Archived reports should always be shown when in default (most recent) mode. This is because you should still be able to access and search for the chats to find them.
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
if (isInDefaultMode && isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) {
if (isInDefaultMode && isArchivedNonExpenseReport(report, !!getReportNameValuePairs(report?.reportID)?.private_isArchived)) {
return CONST.REPORT_IN_LHN_REASONS.IS_ARCHIVED;
}

Expand Down Expand Up @@ -8442,7 +8447,7 @@ function shouldShowFlagComment(reportAction: OnyxInputOrEntry<ReportAction>, rep
canFlagReportAction(reportAction, report?.reportID) &&
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
!isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) &&
!isArchivedNonExpenseReport(report, !!getReportNameValuePairs(report?.reportID)?.private_isArchived) &&
!chatIncludesChronos(report) &&
!isConciergeChatReport(report) &&
reportAction?.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE
Expand Down Expand Up @@ -8786,7 +8791,7 @@ function getWhisperDisplayNames(participantAccountIDs?: number[]): string | unde
function shouldReportShowSubscript(report: OnyxEntry<Report>): boolean {
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && !isWorkspaceThread(report)) {
if (isArchivedNonExpenseReport(report, !!getReportNameValuePairs(report?.reportID)?.private_isArchived) && !isWorkspaceThread(report)) {
return false;
}

Expand Down Expand Up @@ -8905,7 +8910,14 @@ function canUserPerformWriteAction(report: OnyxEntry<Report>) {
// 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);
return !isArchivedNonExpenseReport(report, reportNameValuePairs) && isEmptyObject(reportErrors) && report && isAllowedToComment(report) && !isAnonymousUser && canWriteInReport(report);
return (
!isArchivedNonExpenseReport(report, !!reportNameValuePairs?.private_isArchived) &&
isEmptyObject(reportErrors) &&
report &&
isAllowedToComment(report) &&
!isAnonymousUser &&
canWriteInReport(report)
);
}

/**
Expand Down Expand Up @@ -9015,12 +9027,11 @@ function canEditWriteCapability(report: OnyxEntry<Report>, policy: OnyxEntry<Pol
}

/**
* @param policy - the workspace the report is on, null if the user isn't a member of the workspace
* @param policy - the workspace the room is on, null if the user isn't a member of the workspace
* @param isReportArchived - whether the workspace room is archived
*/
function canEditRoomVisibility(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>): boolean {
// This will get removed as part of https://github.com/Expensify/App/issues/59961
// eslint-disable-next-line deprecation/deprecation
return isPolicyAdminPolicyUtils(policy) && !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID));
function canEditRoomVisibility(policy: OnyxEntry<Policy>, isReportArchived: boolean): boolean {
Comment thread
Tony-MK marked this conversation as resolved.
return !isReportArchived && isPolicyAdminPolicyUtils(policy);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ function sortReportsToDisplayInLHN(
errorReports.push(miniReport);
} else if (hasValidDraftComment(report?.reportID)) {
draftReports.push(miniReport);
} else if (isArchivedNonExpenseReport(report, rNVPs)) {
} else if (isArchivedNonExpenseReport(report, !!rNVPs?.private_isArchived)) {
archivedReports.push(miniReport);
} else {
nonArchivedReports.push(miniReport);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
const [isDebugModeEnabled] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.isDebugModeEnabled, canBeMissing: false});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});

const [isLastMemberLeavingGroupModalVisible, setIsLastMemberLeavingGroupModalVisible] = useState(false);
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
const isPolicyAdmin = useMemo(() => isPolicyAdminUtil(policy), [policy]);
Expand All @@ -178,7 +177,6 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
const isUserCreatedPolicyRoom = useMemo(() => isUserCreatedPolicyRoomUtil(report), [report]);
const isDefaultRoom = useMemo(() => isDefaultRoomUtil(report), [report]);
const isChatThread = useMemo(() => isChatThreadUtil(report), [report]);
const isArchivedRoom = useMemo(() => isArchivedNonExpenseReport(report, reportNameValuePairs), [report, reportNameValuePairs]);
const isMoneyRequestReport = useMemo(() => isMoneyRequestReportUtil(report), [report]);
const isMoneyRequest = useMemo(() => isMoneyRequestUtil(report), [report]);
const isInvoiceReport = useMemo(() => isInvoiceReportUtil(report), [report]);
Expand All @@ -197,6 +195,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
const isSingleTransactionView = isMoneyRequest || isTrackExpenseReport;
const isSelfDMTrackExpenseReport = isTrackExpenseReport && isSelfDMUtil(parentReport);
const isReportArchived = useReportIsArchived(report?.reportID);
const isArchivedRoom = useMemo(() => isArchivedNonExpenseReport(report, isReportArchived), [report, isReportArchived]);
const shouldDisableRename = useMemo(() => shouldDisableRenameUtil(report, isReportArchived), [report, isReportArchived]);
const parentNavigationSubtitleData = getParentNavigationSubtitle(report);
const base62ReportID = getBase62ReportID(Number(report.reportID));
Expand Down
Loading