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
2 changes: 1 addition & 1 deletion Mobile-Expensify
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1009019810
versionName "9.1.98-10"
versionCode 1009019811
versionName "9.1.98-11"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.1.98.10</string>
<string>9.1.98.11</string>
<key>FullStory</key>
<dict>
<key>OrgId</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>9.1.98</string>
<key>CFBundleVersion</key>
<string>9.1.98.10</string>
<string>9.1.98.11</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ShareViewController/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>9.1.98</string>
<key>CFBundleVersion</key>
<string>9.1.98.10</string>
<string>9.1.98.11</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "9.1.98-10",
"version": "9.1.98-11",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
8 changes: 1 addition & 7 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,6 @@ const ONYXKEYS = {
NVP_LAST_ECASH_ANDROID_LOGIN: 'nvp_lastECashAndroidLogin',
NVP_LAST_ANDROID_LOGIN: 'nvp_lastAndroidLogin',

/** Draft report comments */
NVP_DRAFT_REPORT_COMMENTS: 'nvp_draftReportComments',

/** Collection Keys */
COLLECTION: {
DOWNLOAD: 'download_',
Expand Down Expand Up @@ -604,8 +601,7 @@ const ONYXKEYS = {
REPORT_ACTIONS_DRAFTS: 'reportActionsDrafts_',
REPORT_ACTIONS_PAGES: 'reportActionsPages_',
REPORT_ACTIONS_REACTIONS: 'reportActionsReactions_',
/** @deprecated */
REPORT_DRAFT_COMMENT: 'reportDraftComment_', // eslint-disable-line deprecation/deprecation
REPORT_DRAFT_COMMENT: 'reportDraftComment_',
REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_',
REPORT_USER_IS_TYPING: 'reportUserIsTyping_',
REPORT_USER_IS_LEAVING_ROOM: 'reportUserIsLeavingRoom_',
Expand Down Expand Up @@ -1008,7 +1004,6 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS]: OnyxTypes.ReportActionsDrafts;
[ONYXKEYS.COLLECTION.REPORT_ACTIONS_PAGES]: OnyxTypes.Pages;
[ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS]: OnyxTypes.ReportActionReactions;
// eslint-disable-next-line deprecation/deprecation
[ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT]: string;
[ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE]: boolean;
[ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: OnyxTypes.ReportUserIsTyping;
Expand Down Expand Up @@ -1234,7 +1229,6 @@ type OnyxValuesMapping = {
[ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION]: OnboardingAccounting;
[ONYXKEYS.HYBRID_APP]: OnyxTypes.HybridApp;
[ONYXKEYS.NVP_CSV_EXPORT_LAYOUTS]: Record<string, OnyxTypes.ExportTemplate>;
[ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS]: OnyxTypes.DraftReportComments;
};

type OnyxDerivedValuesMapping = {
Expand Down
7 changes: 5 additions & 2 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import useRootNavigationState from '@hooks/useRootNavigationState';
import useScrollEventEmitter from '@hooks/useScrollEventEmitter';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {isValidDraftComment} from '@libs/DraftCommentUtils';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import {getIOUReportIDOfLastAction, getLastMessageTextForReport} from '@libs/OptionsListUtils';
Expand Down Expand Up @@ -52,7 +53,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const [policy] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true});
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: false});
const [draftComments] = useOnyx(ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS, {canBeMissing: true});
const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: false});
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: false});
const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
Expand Down Expand Up @@ -188,7 +189,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
? (getOriginalMessage(itemParentReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID)
: CONST.DEFAULT_NUMBER_ID;
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const hasDraftComment = !!draftComments?.[reportID];
const hasDraftComment = isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);

const isReportArchived = !!itemReportNameValuePairs?.private_isArchived;
const canUserPerformWrite = canUserPerformWriteAction(item, isReportArchived);
Expand Down Expand Up @@ -287,6 +288,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
policy,
personalDetails,
data.length,
draftComments,
optionMode,
preferredLocale,
transactions,
Expand All @@ -303,6 +305,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
policy,
personalDetails,
data.length,
draftComments,
optionMode,
preferredLocale,
transactions,
Expand Down
16 changes: 0 additions & 16 deletions src/hooks/useDiffPrevious.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/usePriorityChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import usePrevious from './usePrevious';

function usePriorityMode() {
const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE, {canBeMissing: true});
const [allReportsWithDraftComments] = useOnyx(ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS, {canBeMissing: true});
const [allReportsWithDraftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true});
const prevPriorityMode = usePrevious(priorityMode);

useEffect(() => {
Expand Down
16 changes: 6 additions & 10 deletions src/hooks/useSidebarOrderedReports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import SidebarUtils from '@libs/SidebarUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import {getEmptyObject} from '@src/types/utils/EmptyObject';
import mapOnyxCollectionItems from '@src/utils/mapOnyxCollectionItems';
import useCurrentReportID from './useCurrentReportID';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDeepCompareRef from './useDeepCompareRef';
import useDiffPrevious from './useDiffPrevious';
import useLocalize from './useLocalize';
import useOnyx from './useOnyx';
import usePrevious from './usePrevious';
Expand Down Expand Up @@ -68,8 +66,7 @@ function SidebarOrderedReportsContextProvider({
const [transactions, {sourceValue: transactionsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true});
const [transactionViolations, {sourceValue: transactionViolationsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true});
const [reportNameValuePairs, {sourceValue: reportNameValuePairsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {canBeMissing: true});
const [drafts = getEmptyObject<OnyxTypes.DraftReportComments>()] = useOnyx(ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS, {canBeMissing: true});
const reportsDraftsUpdates = useDiffPrevious(drafts);
const [, {sourceValue: reportsDraftsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true});
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true});
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (value) => value?.reports, canBeMissing: true});
const [currentReportsToDisplay, setCurrentReportsToDisplay] = useState<ReportsToDisplayInLHN>({});
Expand Down Expand Up @@ -102,8 +99,8 @@ function SidebarOrderedReportsContextProvider({
reportsToUpdate = Object.keys(transactionViolationsUpdates ?? {})
.map((key) => key.replace(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, ONYXKEYS.COLLECTION.TRANSACTION))
.map((key) => `${ONYXKEYS.COLLECTION.REPORT}${transactions?.[key]?.reportID}`);
} else if (reportsDraftsUpdates.length > 0) {
reportsToUpdate = reportsDraftsUpdates.map((key) => `${ONYXKEYS.COLLECTION.REPORT}${key}`);
} else if (reportsDraftsUpdates) {
reportsToUpdate = Object.keys(reportsDraftsUpdates).map((key) => key.replace(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, ONYXKEYS.COLLECTION.REPORT));
} else if (policiesUpdates) {
const updatedPolicies = Object.keys(policiesUpdates).map((key) => key.replace(ONYXKEYS.COLLECTION.POLICY, ''));
reportsToUpdate = Object.entries(chatReports ?? {})
Expand Down Expand Up @@ -154,10 +151,10 @@ function SidebarOrderedReportsContextProvider({
derivedCurrentReportID,
priorityMode === CONST.PRIORITY_MODE.GSD,
betas,
policies,
transactionViolations,
reportNameValuePairs,
reportAttributes,
drafts,
);
} else {
reportsToDisplay = SidebarUtils.getReportsToDisplayInLHN(
Expand All @@ -169,13 +166,12 @@ function SidebarOrderedReportsContextProvider({
transactionViolations,
reportNameValuePairs,
reportAttributes,
drafts,
);
}
return reportsToDisplay;
// Rule disabled intentionally — triggering a re-render on currentReportsToDisplay would cause an infinite loop
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [getUpdatedReports, chatReports, derivedCurrentReportID, priorityMode, betas, policies, transactionViolations, reportNameValuePairs, reportAttributes, reportsDraftsUpdates]);
}, [getUpdatedReports, chatReports, derivedCurrentReportID, priorityMode, betas, policies, transactionViolations, reportNameValuePairs, reportAttributes]);

const deepComparedReportsToDisplayInLHN = useDeepCompareRef(reportsToDisplayInLHN);

Expand All @@ -184,7 +180,7 @@ function SidebarOrderedReportsContextProvider({
}, [reportsToDisplayInLHN]);

const getOrderedReportIDs = useCallback(
() => SidebarUtils.sortReportsToDisplayInLHN(deepComparedReportsToDisplayInLHN ?? {}, priorityMode, localeCompare, reportNameValuePairs, reportAttributes, drafts),
() => SidebarUtils.sortReportsToDisplayInLHN(deepComparedReportsToDisplayInLHN ?? {}, priorityMode, localeCompare, reportNameValuePairs, reportAttributes),
// Rule disabled intentionally - reports should be sorted only when the reportsToDisplayInLHN changes
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[reportsToDisplayInLHN, localeCompare],
Expand Down
6 changes: 0 additions & 6 deletions src/libs/API/parameters/SaveReportDraftCommentParams.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,3 @@ export type {default as ReopenReportParams} from './ReopenReportParams';
export type {default as OpenUnreportedExpensesPageParams} from './OpenUnreportedExpensesPageParams';
export type {default as VerifyTestDriveRecipientParams} from './VerifyTestDriveRecipientParams';
export type {default as ExportSearchWithTemplateParams} from './ExportSearchWithTemplateParams';
export type {default as SaveReportDraftCommentParams} from './SaveReportDraftCommentParams';
2 changes: 0 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type UpdateBeneficialOwnersForBankAccountParams from './parameters/Update
type ApiRequestType = ValueOf<typeof CONST.API_REQUEST_TYPE>;

const WRITE_COMMANDS = {
SAVE_REPORT_DRAFT_COMMENT: 'SaveReportDraftComment',
CLEAN_POLICY_TAGS: 'ClearPolicyTags',
IMPORT_MULTI_LEVEL_TAGS: 'ImportMultiLevelTags',
SET_WORKSPACE_AUTO_REPORTING_FREQUENCY: 'SetWorkspaceAutoReportingFrequency',
Expand Down Expand Up @@ -862,7 +861,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.FINISH_CORPAY_BANK_ACCOUNT_ONBOARDING]: Parameters.FinishCorpayBankAccountOnboardingParams;
[WRITE_COMMANDS.DELETE_VACATION_DELEGATE]: null;
[WRITE_COMMANDS.REOPEN_REPORT]: Parameters.ReopenReportParams;
[WRITE_COMMANDS.SAVE_REPORT_DRAFT_COMMENT]: Parameters.SaveReportDraftCommentParams;

[WRITE_COMMANDS.DELETE_MONEY_REQUEST_ON_SEARCH]: Parameters.DeleteMoneyRequestOnSearchParams;
[WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH]: Parameters.HoldMoneyRequestOnSearchParams;
Expand Down
25 changes: 16 additions & 9 deletions src/libs/DraftCommentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import type {DraftReportComments} from '@src/types/onyx';

let draftComments: OnyxEntry<DraftReportComments> = {};
let draftCommentCollection: OnyxCollection<string> = {};
Onyx.connect({
key: ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS,
key: ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT,
callback: (nextVal) => {
draftComments = nextVal;
draftCommentCollection = nextVal;
},
waitForCollectionCallback: true,
});

/**
Expand All @@ -17,15 +17,22 @@ Onyx.connect({
* A valid use-case of this function is outside React components, like in utility functions.
*/
function getDraftComment(reportID: string): OnyxEntry<string> | null | undefined {
return draftComments?.[reportID];
return draftCommentCollection?.[ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT + reportID];
}

/**
* Returns true if the report has a valid draft comment.
* A valid draft comment is a non-empty string.
*/
function isValidDraftComment(comment?: string | null): boolean {
return !!comment;
}

/**
* Returns true if the report has a valid draft comment.
* NOTE: please prefer useOnyx when possible
*/
function hasValidDraftComment(reportID: string): boolean {
return !!getDraftComment(reportID);
return isValidDraftComment(getDraftComment(reportID));
}

/**
Expand All @@ -37,4 +44,4 @@ function prepareDraftComment(comment: string | null) {
return comment || null;
}

export {getDraftComment, hasValidDraftComment, prepareDraftComment};
export {getDraftComment, isValidDraftComment, hasValidDraftComment, prepareDraftComment};
Loading
Loading