Skip to content

Commit cf56a40

Browse files
authored
Merge pull request Expensify#65414 from linhvovan29546/fix/65228-native-share-tooltip-display-on-wrong-tab
2 parents 2359dcc + 8860c79 commit cf56a40

6 files changed

Lines changed: 31 additions & 5 deletions

File tree

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ function BaseSelectionList<TItem extends ListItem>(
147147
shouldUseDefaultRightHandSideCheckmark,
148148
selectedItems = [],
149149
isSelected,
150+
canShowProductTrainingTooltip,
150151
}: SelectionListProps<TItem>,
151152
ref: ForwardedRef<SelectionListHandle>,
152153
) {
@@ -190,6 +191,10 @@ function BaseSelectionList<TItem extends ListItem>(
190191
[isSelected, selectedItems, canSelectMultiple],
191192
);
192193

194+
const canShowProductTrainingTooltipMemo = useMemo(() => {
195+
return canShowProductTrainingTooltip && isFocused;
196+
}, [canShowProductTrainingTooltip, isFocused]);
197+
193198
/**
194199
* Iterates through the sections and items inside each section, and builds 4 arrays along the way:
195200
* - `allOptions`: Contains all the items in the list, flattened, regardless of section
@@ -618,6 +623,7 @@ function BaseSelectionList<TItem extends ListItem>(
618623
titleStyles={listItemTitleStyles}
619624
singleExecution={singleExecution}
620625
titleContainerStyles={listItemTitleContainerStyles}
626+
canShowProductTrainingTooltip={canShowProductTrainingTooltipMemo}
621627
/>
622628
</View>
623629
);

src/components/SelectionList/BaseSelectionListItemRenderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {isTransactionGroupListItemType} from '@libs/SearchUIUtils';
77
import type {BaseListItemProps, ExtendedTargetedEvent, ListItem, SelectionListProps} from './types';
88

99
type BaseSelectionListItemRendererProps<TItem extends ListItem> = Omit<BaseListItemProps<TItem>, 'onSelectRow'> &
10-
Pick<SelectionListProps<TItem>, 'ListItem' | 'shouldIgnoreFocus' | 'shouldSingleExecuteRowSelect'> & {
10+
Pick<SelectionListProps<TItem>, 'ListItem' | 'shouldIgnoreFocus' | 'shouldSingleExecuteRowSelect' | 'canShowProductTrainingTooltip'> & {
1111
index: number;
1212
selectRow: (item: TItem, indexToFocus?: number) => void;
1313
setFocusedIndex: ReturnType<typeof useArrowKeyFocusManager>[1];
@@ -44,6 +44,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
4444
singleExecution,
4545
titleContainerStyles,
4646
shouldUseDefaultRightHandSideCheckmark,
47+
canShowProductTrainingTooltip = true,
4748
}: BaseSelectionListItemRendererProps<TItem>) {
4849
const handleOnCheckboxPress = () => {
4950
if (isTransactionGroupListItemType(item)) {
@@ -94,6 +95,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
9495
titleStyles={titleStyles}
9596
titleContainerStyles={titleContainerStyles}
9697
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
98+
canShowProductTrainingTooltip={canShowProductTrainingTooltip}
9799
/>
98100
{item.footerContent && item.footerContent}
99101
</>

src/components/SelectionList/InviteMemberListItem.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,21 @@ function InviteMemberListItem<TItem extends ListItem>({
4242
onFocus,
4343
shouldSyncFocus,
4444
wrapperStyle,
45+
canShowProductTrainingTooltip = true,
4546
}: InviteMemberListItemProps<TItem>) {
4647
const styles = useThemeStyles();
4748
const theme = useTheme();
4849
const StyleUtils = useStyleUtils();
4950
const {translate} = useLocalize();
5051
const {isBetaEnabled} = usePermissions();
52+
5153
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip} = useProductTrainingContext(
5254
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP_MANAGER,
53-
!getIsUserSubmittedExpenseOrScannedReceipt() && isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST) && isSelectedManagerMcTest(item.login) && !item.isSelected,
55+
canShowProductTrainingTooltip &&
56+
!getIsUserSubmittedExpenseOrScannedReceipt() &&
57+
isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST) &&
58+
isSelectedManagerMcTest(item.login) &&
59+
!item.isSelected,
5460
);
5561

5662
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;

src/components/SelectionList/types.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ type ListItem<K extends string | number = string> = {
212212

213213
/** Boolean whether to display the right icon */
214214
shouldShowRightIcon?: boolean;
215+
216+
/** Whether product training tooltips can be displayed */
217+
canShowProductTrainingTooltip?: boolean;
215218
};
216219

217220
type TransactionListItemType = ListItem &
@@ -433,7 +436,10 @@ type SplitListItemProps<TItem extends ListItem> = ListItemProps<TItem>;
433436

434437
type TransactionSelectionListItem<TItem extends ListItem> = ListItemProps<TItem> & Transaction;
435438

436-
type InviteMemberListItemProps<TItem extends ListItem> = UserListItemProps<TItem>;
439+
type InviteMemberListItemProps<TItem extends ListItem> = UserListItemProps<TItem> & {
440+
/** Whether product training tooltips can be displayed */
441+
canShowProductTrainingTooltip?: boolean;
442+
};
437443

438444
type UserSelectionListItemProps<TItem extends ListItem> = UserListItemProps<TItem>;
439445

@@ -810,6 +816,9 @@ type SelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
810816

811817
/** Whether to show the default right hand side checkmark */
812818
shouldUseDefaultRightHandSideCheckmark?: boolean;
819+
820+
/** Whether product training tooltips can be displayed */
821+
canShowProductTrainingTooltip?: boolean;
813822
} & TRightHandSideComponent<TItem>;
814823

815824
type SelectionListHandle = {

src/pages/Share/ShareRootPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function ShareRootPage() {
158158
<OnyxTabNavigator
159159
id={CONST.TAB.SHARE.NAVIGATOR_ID}
160160
tabBar={TabSelector}
161+
lazyLoadEnabled
161162
onTabSelect={onTabSelectFocusHandler}
162163
>
163164
<TopTab.Screen name={CONST.TAB.SHARE.SHARE}>{() => <ShareTab ref={shareTabInputRef} />}</TopTab.Screen>

src/pages/iou/request/MoneyRequestParticipantsSelector.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function MoneyRequestParticipantsSelector(
130130
const isCategorizeOrShareAction = [CONST.IOU.ACTION.CATEGORIZE, CONST.IOU.ACTION.SHARE].some((option) => option === action);
131131
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: true});
132132
const hasBeenAddedToNudgeMigration = !!tryNewDot?.nudgeMigration?.timestamp;
133+
const canShowManagerMcTest = useMemo(() => !hasBeenAddedToNudgeMigration && action !== CONST.IOU.ACTION.SUBMIT, [hasBeenAddedToNudgeMigration, action]);
133134

134135
const importAndSaveContacts = useCallback(() => {
135136
contactImport().then(({contactList, permissionStatus}: ContactImportResult) => {
@@ -191,7 +192,7 @@ function MoneyRequestParticipantsSelector(
191192
shouldSeparateSelfDMChat: iouType !== CONST.IOU.TYPE.INVOICE,
192193
shouldSeparateWorkspaceChat: true,
193194
includeSelfDM: !isMovingTransactionFromTrackExpense(action) && iouType !== CONST.IOU.TYPE.INVOICE,
194-
canShowManagerMcTest: !hasBeenAddedToNudgeMigration && action !== CONST.IOU.ACTION.SUBMIT,
195+
canShowManagerMcTest,
195196
isPerDiemRequest,
196197
showRBR: false,
197198
},
@@ -215,7 +216,7 @@ function MoneyRequestParticipantsSelector(
215216
options.reports,
216217
participants,
217218
isPerDiemRequest,
218-
hasBeenAddedToNudgeMigration,
219+
canShowManagerMcTest,
219220
]);
220221

221222
const chatOptions = useMemo(() => {
@@ -615,6 +616,7 @@ function MoneyRequestParticipantsSelector(
615616
shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()}
616617
onSelectRow={onSelectRow}
617618
shouldSingleExecuteRowSelect
619+
canShowProductTrainingTooltip={canShowManagerMcTest}
618620
headerContent={
619621
<ImportContactButton
620622
showImportContacts={showImportContacts}

0 commit comments

Comments
 (0)