Skip to content

Commit

Permalink
Merge branch 'main' into migrateGroup22ToTypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
JKobrynski committed Mar 25, 2024
2 parents 5bf2473 + 9b14272 commit c08893c
Show file tree
Hide file tree
Showing 55 changed files with 406 additions and 276 deletions.
3 changes: 0 additions & 3 deletions __mocks__/@react-native-clipboard/clipboard.js

This file was deleted.

3 changes: 3 additions & 0 deletions __mocks__/@react-native-clipboard/clipboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import clipboardMock from '@react-native-clipboard/clipboard/jest/clipboard-mock';

export default clipboardMock;
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
export default {
getConstants: jest.fn(),
import type {pick, pickDirectory, releaseSecureAccess, types} from 'react-native-document-picker';

type ReactNativeDocumentPickerMock = {
pick: typeof pick;
releaseSecureAccess: typeof releaseSecureAccess;
pickDirectory: typeof pickDirectory;
types: typeof types;
};

const reactNativeDocumentPickerMock: ReactNativeDocumentPickerMock = {
pick: jest.fn(),
releaseSecureAccess: jest.fn(),
pickDirectory: jest.fn(),

types: Object.freeze({
allFiles: 'public.item',
audio: 'public.audio',
Expand All @@ -21,3 +28,5 @@ export default {
zip: 'public.zip-archive',
}),
};

export default reactNativeDocumentPickerMock;
14 changes: 7 additions & 7 deletions desktop/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 desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"electron-context-menu": "^2.3.0",
"electron-log": "^4.4.8",
"electron-serve": "^1.3.0",
"electron-updater": "^6.1.9",
"electron-updater": "^6.2.1",
"node-machine-id": "^1.1.12"
},
"author": "Expensify, Inc.",
Expand Down
71 changes: 0 additions & 71 deletions docs/articles/expensify-classic/settings/Copilot.md

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"analyze-packages": "ANALYZE_BUNDLE=true webpack --config config/webpack/webpack.common.js --env envFile=.env.production",
"symbolicate:android": "npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map",
"symbolicate:ios": "npx metro-symbolicate main.jsbundle.map",
"symbolicate-release:ios": "scripts/release-profile.js --platform=ios",
"symbolicate-release:android": "scripts/release-profile.js --platform=android",
"symbolicate-release:ios": "scripts/release-profile.ts --platform=ios",
"symbolicate-release:android": "scripts/release-profile.ts --platform=android",
"test:e2e": "ts-node tests/e2e/testRunner.ts --config ./config.local.ts",
"test:e2e:dev": "ts-node tests/e2e/testRunner.ts --config ./config.dev.ts",
"gh-actions-unused-styles": "./.github/scripts/findUnusedKeys.sh",
Expand Down
20 changes: 12 additions & 8 deletions scripts/release-profile.js → scripts/release-profile.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env node
#!/usr/bin/env ts-node

/* eslint-disable no-console */
import {execSync} from 'child_process';
import fs from 'fs';

const fs = require('fs');
const {execSync} = require('child_process');
type ArgsMap = Record<string, string>;

// Function to parse command-line arguments into a key-value object
function parseCommandLineArguments() {
function parseCommandLineArguments(): ArgsMap {
const args = process.argv.slice(2); // Skip node and script paths
const argsMap = {};
const argsMap: ArgsMap = {};
args.forEach((arg) => {
const [key, value] = arg.split('=');
if (key.startsWith('--')) {
Expand All @@ -20,14 +22,13 @@ function parseCommandLineArguments() {
// Function to find .cpuprofile files in the current directory
function findCpuProfileFiles() {
const files = fs.readdirSync(process.cwd());
// eslint-disable-next-line rulesdir/prefer-underscore-method
return files.filter((file) => file.endsWith('.cpuprofile'));
}

const argsMap = parseCommandLineArguments();

// Determine sourcemapPath based on the platform flag passed
let sourcemapPath;
let sourcemapPath: string | undefined;
if (argsMap.platform === 'ios') {
sourcemapPath = 'main.jsbundle.map';
} else if (argsMap.platform === 'android') {
Expand Down Expand Up @@ -57,7 +58,10 @@ if (cpuProfiles.length === 0) {
const output = execSync(command, {stdio: 'inherit'});
console.log(output.toString());
} catch (error) {
console.error(`Error executing command: ${error}`);
if (error instanceof Error) {
console.error(`Error executing command: ${error.toString()}`);
}

process.exit(1);
}
}
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ const CONST = {
TRACK_EXPENSE: 'trackExpense',
P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests',
WORKFLOWS_DELAYED_SUBMISSION: 'workflowsDelayedSubmission',
ACCOUNTING: 'accounting',
},
BUTTON_STATES: {
DEFAULT: 'default',
Expand Down
8 changes: 4 additions & 4 deletions src/libs/ErrorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ function getAuthenticateErrorMessage(response: Response): keyof TranslationFlatO
* Method used to get an error object with microsecond as the key.
* @param error - error key or message to be saved
*/
function getMicroSecondOnyxError(error: string | null, isTranslated = false): Errors {
return {[DateUtils.getMicroseconds()]: error && [error, {isTranslated}]};
function getMicroSecondOnyxError(error: string | null, isTranslated = false, errorKey?: number): Errors {
return {[errorKey ?? DateUtils.getMicroseconds()]: error && [error, {isTranslated}]};
}

/**
* Method used to get an error object with microsecond as the key and an object as the value.
* @param error - error key or message to be saved
*/
function getMicroSecondOnyxErrorObject(error: Errors): ErrorFields {
return {[DateUtils.getMicroseconds()]: error};
function getMicroSecondOnyxErrorObject(error: Errors, errorKey?: number): ErrorFields {
return {[errorKey ?? DateUtils.getMicroseconds()]: error};
}

// We can assume that if error is a string, it has already been translated because it is server error
Expand Down
6 changes: 3 additions & 3 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {PolicyTagList, ReportAction} from '@src/types/onyx';
import * as CurrencyUtils from './CurrencyUtils';
import DateUtils from './DateUtils';
import getReportPolicyID from './getReportPolicyID';
import * as Localize from './Localize';
import * as PolicyUtils from './PolicyUtils';
import * as ReportUtils from './ReportUtils';
import type {ExpenseOriginalMessage} from './ReportUtils';
import * as TransactionUtils from './TransactionUtils';

Expand Down Expand Up @@ -97,12 +97,12 @@ function getForDistanceRequest(newDistance: string, oldDistance: string, newAmou
* ModifiedExpense::getNewDotComment in Web-Expensify should match this.
* If we change this function be sure to update the backend as well.
*/
function getForReportAction(reportID: string | undefined, reportAction: OnyxEntry<ReportAction>): string {
function getForReportAction(reportID: string | undefined, reportAction: OnyxEntry<ReportAction> | ReportAction | Record<string, never>): string {
if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) {
return '';
}
const reportActionOriginalMessage = reportAction?.originalMessage as ExpenseOriginalMessage | undefined;
const policyID = ReportUtils.getReportPolicyID(reportID) ?? '';
const policyID = getReportPolicyID(reportID) ?? '';

const removalFragments: string[] = [];
const setFragments: string[] = [];
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function canUseWorkflowsDelayedSubmission(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.WORKFLOWS_DELAYED_SUBMISSION) || canUseAllBetas(betas);
}

function canUseAccountingIntegrations(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.ACCOUNTING) || canUseAllBetas(betas);
}

/**
* Link previews are temporarily disabled.
*/
Expand All @@ -55,4 +59,5 @@ export default {
canUseReportFields,
canUseP2PDistanceRequests,
canUseWorkflowsDelayedSubmission,
canUseAccountingIntegrations,
};
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function isReportPreviewAction(reportAction: OnyxEntry<ReportAction>): boolean {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW;
}

function isModifiedExpenseAction(reportAction: OnyxEntry<ReportAction>): boolean {
function isModifiedExpenseAction(reportAction: OnyxEntry<ReportAction> | ReportAction | Record<string, never>): boolean {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE;
}

Expand Down
7 changes: 6 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ import * as store from './actions/ReimbursementAccount/store';
import * as CollectionUtils from './CollectionUtils';
import * as CurrencyUtils from './CurrencyUtils';
import DateUtils from './DateUtils';
import originalGetReportPolicyID from './getReportPolicyID';
import isReportMessageAttachment from './isReportMessageAttachment';
import localeCompare from './LocaleCompare';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as Localize from './Localize';
import {isEmailPublicDomain} from './LoginUtils';
import ModifiedExpenseMessage from './ModifiedExpenseMessage';
import linkingConfig from './Navigation/linkingConfig';
import Navigation from './Navigation/Navigation';
import * as NumberUtils from './NumberUtils';
Expand Down Expand Up @@ -2772,6 +2774,9 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
if (parentReportActionMessage && isArchivedRoom(report)) {
return `${parentReportActionMessage} (${Localize.translateLocal('common.archived')})`;
}
if (ReportActionsUtils.isModifiedExpenseAction(parentReportAction)) {
return ModifiedExpenseMessage.getForReportAction(report?.reportID, parentReportAction);
}
return parentReportActionMessage;
}

Expand Down Expand Up @@ -4619,7 +4624,7 @@ function getReportIDFromLink(url: string | null): string {
* Get the report policyID given a reportID
*/
function getReportPolicyID(reportID?: string): string | undefined {
return getReport(reportID)?.policyID;
return originalGetReportPolicyID(reportID);
}

/**
Expand Down
Loading

0 comments on commit c08893c

Please sign in to comment.