Skip to content

Commit

Permalink
Merge branch 'main' into feature/migrate-MoneyReportHeaderStatusBar
Browse files Browse the repository at this point in the history
  • Loading branch information
pasyukevich committed Dec 19, 2023
2 parents 480bdfa + aa1d87c commit db468c8
Show file tree
Hide file tree
Showing 203 changed files with 3,901 additions and 3,215 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const restrictedImportPaths = [
importNames: ['TouchableOpacity', 'TouchableWithoutFeedback', 'TouchableNativeFeedback', 'TouchableHighlight'],
message: "Please use 'PressableWithFeedback' and/or 'PressableWithoutFeedback' from 'src/components/Pressable' instead.",
},
{
name: 'awesome-phonenumber',
importNames: ['parsePhoneNumber'],
message: "Please use '@libs/PhoneNumber' instead.",
},
{
name: 'react-native-safe-area-context',
importNames: ['useSafeAreaInsets', 'SafeAreaConsumer', 'SafeAreaInsetsContext'],
Expand Down
8 changes: 6 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ GEM
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20231109)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.8.1)
emoji_regex (3.2.3)
escape (0.0.4)
Expand Down Expand Up @@ -261,6 +262,9 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.9.1)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
Expand Down Expand Up @@ -294,4 +298,4 @@ RUBY VERSION
ruby 2.6.10p210

BUNDLED WITH
2.1.4
2.4.7
1 change: 1 addition & 0 deletions __mocks__/@ua/react-native-airship.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Airship = {
enableUserNotifications: () => Promise.resolve(false),
clearNotifications: jest.fn(),
getNotificationStatus: () => Promise.resolve({airshipOptIn: false, systemEnabled: false}),
getActiveNotifications: () => Promise.resolve([]),
},
contact: {
identify: jest.fn(),
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001041304
versionName "1.4.13-4"
versionCode 1001041400
versionName "1.4.14-0"
}

flavorDimensions "default"
Expand Down
Binary file modified assets/animations/Fireworks.lottie
Binary file not shown.
Binary file modified assets/animations/ReviewingBankInfo.lottie
Binary file not shown.
123 changes: 120 additions & 3 deletions contributingGuides/TS_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- [1.17 `.tsx`](#tsx)
- [1.18 No inline prop types](#no-inline-prop-types)
- [1.19 Satisfies operator](#satisfies-operator)
- [1.20 Hooks instead of HOCs](#hooks-instead-of-hocs)
- [1.21 `compose` usage](#compose-usage)
- [Exception to Rules](#exception-to-rules)
- [Communication Items](#communication-items)
- [Migration Guidelines](#migration-guidelines)
Expand Down Expand Up @@ -124,7 +126,7 @@ type Foo = {

<a name="d-ts-extension"></a><a name="1.2"></a>

- [1.2](#d-ts-extension) **`d.ts` Extension**: Do not use `d.ts` file extension even when a file contains only type declarations. Only exceptions are `src/types/global.d.ts` and `src/types/modules/*.d.ts` files in which third party packages can be modified using module augmentation. Refer to the [Communication Items](#communication-items) section to learn more about module augmentation.
- [1.2](#d-ts-extension) **`d.ts` Extension**: Do not use `d.ts` file extension even when a file contains only type declarations. Only exceptions are `src/types/global.d.ts` and `src/types/modules/*.d.ts` files in which third party packages and JavaScript's built-in modules (e.g. `window` object) can be modified using module augmentation. Refer to the [Communication Items](#communication-items) section to learn more about module augmentation.
> Why? Type errors in `d.ts` files are not checked by TypeScript [^1].
Expand Down Expand Up @@ -509,6 +511,102 @@ type Foo = {
} satisfies Record<string, ViewStyle>;
```

<a name="hooks-instead-of-hocs"></a><a name="1.20"></a>

- [1.20](#hooks-instead-of-hocs) **Hooks instead of HOCs**: Replace HOCs usage with Hooks whenever possible.

> Why? Hooks are easier to use (can be used inside the function component), and don't need nesting or `compose` when exporting the component. It also allows us to remove `compose` completely in some components since it has been bringing up some issues with TypeScript. Read the [`compose` usage](#compose-usage) section for further information about the TypeScript issues with `compose`.
> Note: Because Onyx doesn't provide a hook yet, in a component that accesses Onyx data with `withOnyx` HOC, please make sure that you don't use other HOCs (if applicable) to avoid HOC nesting.
```tsx
// BAD
type ComponentOnyxProps = {
session: OnyxEntry<Session>;
};

type ComponentProps = WindowDimensionsProps &
WithLocalizeProps &
ComponentOnyxProps & {
someProp: string;
};

function Component({windowWidth, windowHeight, translate, session, someProp}: ComponentProps) {
// component's code
}

export default compose(
withWindowDimensions,
withLocalize,
withOnyx<ComponentProps, ComponentOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
}),
)(Component);

// GOOD
type ComponentOnyxProps = {
session: OnyxEntry<Session>;
};

type ComponentProps = ComponentOnyxProps & {
someProp: string;
};

function Component({session, someProp}: ComponentProps) {
const {windowWidth, windowHeight} = useWindowDimensions();
const {translate} = useLocalize();
// component's code
}

// There is no hook alternative for withOnyx yet.
export default withOnyx<ComponentProps, ComponentOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
})(Component);
```

<a name="compose-usage"></a><a name="1.21"></a>

- [1.21](#compose-usage) **`compose` usage**: Avoid the usage of `compose` function to compose HOCs in TypeScript files. Use nesting instead.

> Why? `compose` function doesn't work well with TypeScript when dealing with several HOCs being used in a component, many times resulting in wrong types and errors. Instead, nesting can be used to allow a seamless use of multiple HOCs and result in a correct return type of the compoment. Also, you can use [hooks instead of HOCs](#hooks-instead-of-hocs) whenever possible to minimize or even remove the need of HOCs in the component.
```ts
// BAD
export default compose(
withCurrentUserPersonalDetails,
withReportOrNotFound(),
withOnyx<ComponentProps, ComponentOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
}),
)(Component);

// GOOD
export default withCurrentUserPersonalDetails(
withReportOrNotFound()(
withOnyx<ComponentProps, ComponentOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
})(Component),
),
);

// GOOD - alternative to HOC nesting
const ComponentWithOnyx = withOnyx<ComponentProps, ComponentOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
})(Component);
const ComponentWithReportOrNotFound = withReportOrNotFound()(ComponentWithOnyx);
export default withCurrentUserPersonalDetails(ComponentWithReportOrNotFound);
```

## Exception to Rules

Most of the rules are enforced in ESLint or checked by TypeScript. If you think your particular situation warrants an exception, post the context in the `#expensify-open-source` Slack channel with your message prefixed with `TS EXCEPTION:`. The internal engineer assigned to the PR should be the one that approves each exception, however all discussion regarding granting exceptions should happen in the public channel instead of the GitHub PR page so that the TS migration team can access them easily.
Expand All @@ -521,7 +619,7 @@ This rule will apply until the migration is done. After the migration, discussio

> Comment in the `#expensify-open-source` Slack channel if any of the following situations are encountered. Each comment should be prefixed with `TS ATTENTION:`. Internal engineers will access each situation and prescribe solutions to each case. Internal engineers should refer to general solutions to each situation that follows each list item.
- I think types definitions in a third party library is incomplete or incorrect
- I think types definitions in a third party library or JavaScript's built-in module are incomplete or incorrect

When the library indeed contains incorrect or missing type definitions and it cannot be updated, use module augmentation to correct them. All module augmentation code should be contained in `/src/types/modules/*.d.ts`, each library as a separate file.

Expand All @@ -540,7 +638,7 @@ declare module "external-library-name" {

> This section contains instructions that are applicable during the migration.
- 🚨 DO NOT write new code in TypeScript yet. The only time you write TypeScript code is when the file you're editing has already been migrated to TypeScript by the migration team. This guideline will be updated once it's time for new code to be written in TypeScript. If you're doing a major overhaul or refactoring of particular features or utilities of App and you believe it might be beneficial to migrate relevant code to TypeScript as part of the refactoring, please ask in the #expensify-open-source channel about it (and prefix your message with `TS ATTENTION:`).
- 🚨 DO NOT write new code in TypeScript yet. The only time you write TypeScript code is when the file you're editing has already been migrated to TypeScript by the migration team, or when you need to add new files under `src/libs`, `src/hooks`, `src/styles`, and `src/languages` directories. This guideline will be updated once it's time for new code to be written in TypeScript. If you're doing a major overhaul or refactoring of particular features or utilities of App and you believe it might be beneficial to migrate relevant code to TypeScript as part of the refactoring, please ask in the #expensify-open-source channel about it (and prefix your message with `TS ATTENTION:`).

- If you're migrating a module that doesn't have a default implementation (i.e. `index.ts`, e.g. `getPlatform`), convert `index.website.js` to `index.ts`. Without `index.ts`, TypeScript cannot get type information where the module is imported.

Expand Down Expand Up @@ -579,6 +677,25 @@ object?.foo ?? 'bar';
const y: number = 123; // TS error: Unused '@ts-expect-error' directive.
```

- The TS issue I'm working on is blocked by another TS issue because of type errors. What should I do?

In order to proceed with the migration faster, we are now allowing the use of `@ts-expect-error` annotation to temporally suppress those errors and help you unblock your issues. The only requirements is that you MUST add the annotation with a comment explaining that it must be removed when the blocking issue is migrated, e.g.:

```tsx
return (
<MenuItem
// @ts-expect-error TODO: Remove this once MenuItem (https://github.com/Expensify/App/issues/25144) is migrated to TypeScript.
wrapperStyle={styles.mr3}
key={text}
icon={icon}
title={text}
onPress={onPress}
/>
);
```

**You will also need to reference the blocking issue in your PR.** You can find all the TS issues [here](https://github.com/orgs/Expensify/projects/46).

## Learning Resources

### Quickest way to learn TypeScript
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Budgets
description: Track employee spending across categories and tags by using Expensify's Budgets feature.
---

# About
Expensify’s Budgets feature allows you to:
- Set monthly and yearly budgets
- Track spending across categories and tags on an individual and workspace basis
- Get notified when a budget has met specific thresholds

# How-to
## Category Budgets
1. Navigate to **Settings > Group > [Workspace Name] > Categories**
2. Click the **Edit Rules** button for the category you want to add a budget to
3. Select the **Budget** tab at the top of the modal that opens
4. Click the switch next to **Enable Budget**
5. Once enabled, you will see additional settings to configure:
- **Budget frequency**: you can select if you want this to be a monthly or a yearly budget
- **Total workspace budget**: you can enter an amount if you want to set a budget for the entire workspace
- **Per individual budget**: you can enter an amount if you want to set a budget per person
- **Notification threshold** - this is the % in which you will be notified as the budgets are hit

## Single-level Tag Budgets
1. Navigate to **Settings > Group > [Workspace Name] > Tags**
2. Click **Edit Budget** next to the tag you want to add a budget to
3. Click the switch next to **Enable Budget**
4. Once enabled, you will see additional settings to configure:
- **Budget frequency**: you can select if you want this to be a monthly or a yearly budget
- **Total workspace budget**: you can enter an amount if you want to set a budget for the entire workspace
- **Per individual budget**: you can enter an amount if you want to set a budget per person
- **Notification threshold** - this is the % in which you will be notified as the budgets are hit

## Multi-level Tag Budgets
1. Navigate to **Settings > Group > [Workspace Name] > Tags**
2. Click the **Edit Tags** button
3. Click the **Edit Budget** button next to the subtag you want to apply a budget to
4. Click the switch next to **Enable Budget**
5. Once enabled, you will see additional settings to configure:
- **Budget frequency**: you can select if you want this to be a monthly or a yearly budget
- **Total workspace budget**: you can enter an amount if you want to set a budget for the entire workspace
- **Per individual budget**: you can enter an amount if you want to set a budget per person
- **Notification threshold** - this is the % in which you will be notified as the budgets are hit

# FAQ
## Can I import budgets as a CSV?
At this time, you cannot import budgets via CSV since we don’t import categories or tags from direct accounting integrations.

## When will I be notified as a budget is hit?
Notifications are sent twice:
- When your notification threshold is hit (i.e, if you set this as 50%, you’ll be notified when 50% of the budget is met)
- When 100% of the budget is met

## How will I be notified when a budget is hit?
A message will be sent in the #admins room of the Workspace.

9 changes: 6 additions & 3 deletions docs/articles/new-expensify/get-paid-back/Referral-Program.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ As a thank you, every time you bring a new customer into New Expensify, you'll g

# How to get paid to refer anyone to New Expensify

The sky's the limit for this referral program! Your referral can be anyone - a friend, family member, boss, coworker, neighbor, or even social media follower. We're making it as easy as possible to get that cold hard referral $$$.
The sky's the limit for this referral program! Your referral can be anyone - a friend, family member, boss, coworker, neighbor, or even social media follower. We're making it as easy as possible to get that cold hard $$$.

1. There are a bunch of different ways to kick off a referral in New Expensify:
1. There are a bunch of different ways to refer someone to New Expensify:
- Start a chat
- Request money
- Send money
- @ mention someone
- Split a bill
- Assign them a task
- @ mention them
- Invite them to a room
- Add them to a workspace

2. You'll get $250 for each referral as long as:
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.13</string>
<string>1.4.14</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.4.13.4</string>
<string>1.4.14.0</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.13</string>
<string>1.4.14</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.13.4</string>
<string>1.4.14.0</string>
</dict>
</plist>
Loading

0 comments on commit db468c8

Please sign in to comment.