Skip to content

Commit a709185

Browse files
Merge branch 'main' into garrettmknight-patch-3
2 parents ada0880 + d66b791 commit a709185

28 files changed

Lines changed: 83 additions & 251 deletions

File tree

Mobile-Expensify

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ android {
114114
minSdkVersion rootProject.ext.minSdkVersion
115115
targetSdkVersion rootProject.ext.targetSdkVersion
116116
multiDexEnabled rootProject.ext.multiDexEnabled
117-
versionCode 1009018502
118-
versionName "9.1.85-2"
117+
versionCode 1009018504
118+
versionName "9.1.85-4"
119119
// Supported language variants must be declared here to avoid from being removed during the compilation.
120120
// This also helps us to not include unnecessary language variants in the APK.
121121
resConfigs "en", "es"

ios/NewExpensify/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</dict>
4545
</array>
4646
<key>CFBundleVersion</key>
47-
<string>9.1.85.2</string>
47+
<string>9.1.85.4</string>
4848
<key>FullStory</key>
4949
<dict>
5050
<key>OrgId</key>

ios/NotificationServiceExtension/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<key>CFBundleShortVersionString</key>
1414
<string>9.1.85</string>
1515
<key>CFBundleVersion</key>
16-
<string>9.1.85.2</string>
16+
<string>9.1.85.4</string>
1717
<key>NSExtension</key>
1818
<dict>
1919
<key>NSExtensionPointIdentifier</key>

ios/ShareViewController/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<key>CFBundleShortVersionString</key>
1414
<string>9.1.85</string>
1515
<key>CFBundleVersion</key>
16-
<string>9.1.85.2</string>
16+
<string>9.1.85.4</string>
1717
<key>NSExtension</key>
1818
<dict>
1919
<key>NSExtensionAttributes</key>

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "new.expensify",
3-
"version": "9.1.85-2",
3+
"version": "9.1.85-4",
44
"author": "Expensify, Inc.",
55
"homepage": "https://new.expensify.com",
66
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
@@ -129,7 +129,7 @@
129129
"date-fns-tz": "^3.2.0",
130130
"dom-serializer": "^0.2.2",
131131
"domhandler": "^4.3.0",
132-
"expensify-common": "^2.0.142",
132+
"expensify-common": "2.0.147",
133133
"expo": "53.0.7",
134134
"expo-asset": "^11.1.2",
135135
"expo-av": "^15.1.5",

src/CONST/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5204,7 +5204,7 @@ const CONST = {
52045204
* The maximum count of items per page for SelectionList.
52055205
* When paginate, it multiplies by page number.
52065206
*/
5207-
MAX_SELECTION_LIST_PAGE_LENGTH: 50,
5207+
MAX_SELECTION_LIST_PAGE_LENGTH: 500,
52085208

52095209
/**
52105210
* Bank account names

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -167,34 +167,10 @@ function BaseSelectionList<TItem extends ListItem>(
167167
const {isKeyboardShown} = useKeyboardState();
168168
const [itemsToHighlight, setItemsToHighlight] = useState<Set<string> | null>(null);
169169
const itemFocusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
170-
const isItemSelected = useCallback(
171-
(item: TItem) => item.isSelected ?? ((isSelected?.(item) ?? selectedItems.includes(item.keyForList ?? '')) && canSelectMultiple),
172-
[isSelected, selectedItems, canSelectMultiple],
173-
);
174-
/** Calculates on which page is selected item so we can scroll to it on first render */
175-
const calculateInitialCurrentPage = useCallback(() => {
176-
if (canSelectMultiple || sections.length === 0) {
177-
return 1;
178-
}
179-
180-
let currentIndex = 0;
181-
for (const section of sections) {
182-
if (section.data) {
183-
for (const item of section.data) {
184-
if (isItemSelected(item)) {
185-
return Math.floor(currentIndex / CONST.MAX_SELECTION_LIST_PAGE_LENGTH) + 1;
186-
}
187-
currentIndex++;
188-
}
189-
}
190-
}
191-
return 1;
192-
}, [canSelectMultiple, isItemSelected, sections]);
193-
const [currentPage, setCurrentPage] = useState(() => calculateInitialCurrentPage());
170+
const [currentPage, setCurrentPage] = useState(1);
194171
const isTextInputFocusedRef = useRef<boolean>(false);
195172
const {singleExecution} = useSingleExecution();
196173
const [itemHeights, setItemHeights] = useState<Record<string, number>>({});
197-
const pendingScrollIndexRef = useRef<number | null>(null);
198174

199175
const onItemLayout = (event: LayoutChangeEvent, itemKey: string | null | undefined) => {
200176
if (!itemKey) {
@@ -211,6 +187,11 @@ function BaseSelectionList<TItem extends ListItem>(
211187

212188
const incrementPage = () => setCurrentPage((prev) => prev + 1);
213189

190+
const isItemSelected = useCallback(
191+
(item: TItem) => item.isSelected ?? ((isSelected?.(item) ?? selectedItems.includes(item.keyForList ?? '')) && canSelectMultiple),
192+
[isSelected, selectedItems, canSelectMultiple],
193+
);
194+
214195
const canShowProductTrainingTooltipMemo = useMemo(() => {
215196
return canShowProductTrainingTooltip && isFocused;
216197
}, [canShowProductTrainingTooltip, isFocused]);
@@ -343,17 +324,6 @@ function BaseSelectionList<TItem extends ListItem>(
343324
return;
344325
}
345326

346-
// Calculate which page is needed to show this index
347-
const requiredPage = Math.ceil((index + 1) / CONST.MAX_SELECTION_LIST_PAGE_LENGTH);
348-
349-
// If the required page is beyond the current page, load all pages up to it,
350-
// then return early and let the scroll happen after the page update
351-
if (requiredPage > currentPage) {
352-
pendingScrollIndexRef.current = index;
353-
setCurrentPage(requiredPage);
354-
return;
355-
}
356-
357327
const itemIndex = item.index ?? -1;
358328
const sectionIndex = item.sectionIndex ?? -1;
359329
let viewOffsetToKeepFocusedItemAtTopOfViewableArea = 0;
@@ -370,11 +340,10 @@ function BaseSelectionList<TItem extends ListItem>(
370340
}
371341

372342
listRef.current.scrollToLocation({sectionIndex, itemIndex, animated, viewOffset: variables.contentHeaderHeight - viewOffsetToKeepFocusedItemAtTopOfViewableArea});
373-
pendingScrollIndexRef.current = null;
374343
},
375344

376345
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
377-
[flattenedSections.allOptions, currentPage],
346+
[flattenedSections.allOptions],
378347
);
379348

380349
const [disabledArrowKeyIndexes, setDisabledArrowKeyIndexes] = useState(flattenedSections.disabledArrowKeyOptionsIndexes);
@@ -387,21 +356,6 @@ function BaseSelectionList<TItem extends ListItem>(
387356
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
388357
}, [flattenedSections.disabledArrowKeyOptionsIndexes]);
389358

390-
/** Check whether there is a need to scroll to an item and if all items are loaded */
391-
useEffect(() => {
392-
if (pendingScrollIndexRef.current === null) {
393-
return;
394-
}
395-
396-
const indexToScroll = pendingScrollIndexRef.current;
397-
const targetItem = flattenedSections.allOptions.at(indexToScroll);
398-
399-
if (targetItem && indexToScroll < CONST.MAX_SELECTION_LIST_PAGE_LENGTH * currentPage) {
400-
pendingScrollIndexRef.current = null;
401-
scrollToIndex(indexToScroll, true);
402-
}
403-
}, [currentPage, scrollToIndex, flattenedSections.allOptions]);
404-
405359
const debouncedScrollToIndex = useMemo(() => lodashDebounce(scrollToIndex, CONST.TIMING.LIST_SCROLLING_DEBOUNCE_TIME, {leading: true, trailing: true}), [scrollToIndex]);
406360

407361
const setHasKeyBeenPressed = useCallback(() => {
@@ -816,28 +770,17 @@ function BaseSelectionList<TItem extends ListItem>(
816770
) {
817771
return;
818772
}
819-
// Reset the current page to 1 when the user types something
820-
if (prevTextInputValue !== textInputValue) {
821-
setCurrentPage(1);
822-
}
823-
824-
// When clearing the search, scroll to the selected item if one exists
825-
if (prevTextInputValue !== '' && textInputValue === '') {
826-
const foundSelectedItemIndex = flattenedSections.allOptions.findIndex(isItemSelected);
827-
if (foundSelectedItemIndex !== -1) {
828-
updateAndScrollToFocusedIndex(foundSelectedItemIndex);
829-
return;
830-
}
831-
}
832-
833773
// Remove the focus if the search input is empty and prev search input not empty or selected options length is changed (and allOptions length remains the same)
834774
// else focus on the first non disabled item
835775
const newSelectedIndex =
836-
(prevTextInputValue !== '' && textInputValue === '') ||
776+
(isEmpty(prevTextInputValue) && textInputValue === '') ||
837777
(flattenedSections.selectedOptions.length !== prevSelectedOptionsLength && prevAllOptionsLength === flattenedSections.allOptions.length)
838778
? -1
839779
: 0;
840780

781+
// Reset the current page to 1 when the user types something
782+
setCurrentPage(1);
783+
841784
updateAndScrollToFocusedIndex(newSelectedIndex);
842785
}, [
843786
canSelectMultiple,
@@ -849,8 +792,6 @@ function BaseSelectionList<TItem extends ListItem>(
849792
prevSelectedOptionsLength,
850793
prevAllOptionsLength,
851794
shouldUpdateFocusedIndex,
852-
flattenedSections.allOptions,
853-
isItemSelected,
854795
]);
855796

856797
useEffect(

src/components/SelectionList/Search/UserSelectionListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function UserSelectionListItem<TItem extends ListItem>({
6060
const userDisplayName = useMemo(() => {
6161
return getDisplayNameForParticipant({
6262
accountID: item.accountID ?? CONST.DEFAULT_NUMBER_ID,
63+
shouldAddCurrentUserPostfix: true,
6364
});
6465
}, [item.accountID]);
6566

0 commit comments

Comments
 (0)