Skip to content

Move Str methods that other Str methods call to module-level functions - #952

Merged
mountiny merged 1 commit into
Expensify:mainfrom
collectioneur:collectioneur/move-str-to-module-level-functions
Oct 6, 2026
Merged

mountiny merged 1 commit into
Expensify:mainfrom
collectioneur:collectioneur/move-str-to-module-level-functions

Conversation

@collectioneur

@collectioneur collectioneur commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

react-native-worklets 0.13 removed Worklet Context Objects (software-mansion/react-native-reanimated#10411). In App without Bundle Mode (our default Re.Pack builds), this inside Str methods no longer points to Str on the LiveMarkdownRuntime. As a result, typing a link in the composer crashes in Str.sanitizeURL → this.cutBefore.

This PR moves the Str methods that other Str methods call to module-level functions in lib/str.ts and calls them directly instead of through this:

compare, caseInsensitiveCompare, contains, cutAfter, cutBefore, extractEmailDomain, getExtension, getRawByteSize, htmlDecode, htmlEncode, isTypeOf, isNumber, isString, isUndefined, isValidE164Phone, isValidEmail, maskFirstNCharacters, removeSMSDomain, removeTrailingComma, startsWith

Every one of them is still exposed on Str under the same name with the same JSDoc, so the public Str API and behavior are unchanged. There are no this. references left in lib/str.ts.

This is the upstream version of the expensify-common patch added in Expensify/App#102266 (the reanimated 4.7.0 / worklets 0.13.0 upgrade). Once this is released and App bumps expensify-common, that patch can be removed.

Fixed Issues

$ Expensify/App#101440

Tests

  1. Existing unit tests cover the change: __tests__/Str-test.js covers the Str methods, and the ExpensiMark tests exercise Str indirectly.
  2. Ran npx tsc --noEmit, npx eslint lib/str.ts, npm run build and npx jest: no type or lint errors, and all 569 tests pass.

QA

  1. Tested in App through Bump react-native-reanimated to 4.7.0 and react-native-worklets to 0.13.0 App#102266, where the same change is applied as a patch. On iOS and Android, open a chat and type *bold* _italic_ ~strike~ `code` @here https://expensify.com. Verify the formatting is applied live and that typing the link does not crash. Repeat on web.

@collectioneur collectioneur changed the title move the Str methods that other Str methods call to module-level func… Move Str methods that other Str methods call to module-level functions Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@collectioneur
collectioneur marked this pull request as ready for review October 6, 2026 15:09
@collectioneur
collectioneur requested a review from a team as a code owner October 6, 2026 15:09
@melvin-bot
melvin-bot Bot requested review from marcaaron and removed request for a team October 6, 2026 15:09
@collectioneur

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

exfy-clabot Bot added a commit to Expensify/CLA that referenced this pull request Oct 6, 2026

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I will move this ahead as we need this to be merged before continuing with prs required for expo and react native upgrades

@mountiny
mountiny merged commit 62179b0 into Expensify:main Oct 6, 2026
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants