Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move free trial banner to #admins room for users selecting MANAGE_TEAM onboarding intent #53895

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
254bd0e
move free trial banner to admins room
c3024 Dec 11, 2024
640d83b
free trial logic for header for manage team intent
c3024 Dec 11, 2024
56ee397
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Dec 16, 2024
37c60be
prettier
c3024 Dec 16, 2024
472f435
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Dec 17, 2024
b187a0e
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Dec 18, 2024
51c1483
prettier
c3024 Dec 18, 2024
9134cda
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Dec 19, 2024
8156350
fix lint
c3024 Dec 19, 2024
b546542
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Dec 19, 2024
cf4dc60
fix potential errors due to lint changes
c3024 Dec 19, 2024
4d323fc
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Jan 7, 2025
b437baf
remove redundant comment
c3024 Jan 9, 2025
60c67c9
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Jan 13, 2025
8afaca3
make the comment to explain the why
c3024 Jan 14, 2025
eafed51
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Jan 14, 2025
e0f61fc
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Jan 15, 2025
6800e0e
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Jan 16, 2025
41716d5
use named reports to fix lint errors
c3024 Jan 16, 2025
116cda6
use named imports to fix lint errors
c3024 Jan 16, 2025
4c9d7cf
Merge branch 'main' into move-free-trial-banner-to-admins-room-for-ma…
c3024 Jan 16, 2025
31bd5c9
remove fallback for string reportID
c3024 Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import DateUtils from '@libs/DateUtils';
import DomUtils from '@libs/DomUtils';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import {shouldOptionShowTooltip, shouldUseBoldText} from '@libs/OptionsListUtils';
import Parser from '@libs/Parser';
import Performance from '@libs/Performance';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportUtils from '@libs/ReportUtils';
import {
isAdminRoom,
isChatUsedForOnboarding,
isConciergeChatReport,
isGroupChat,
isOneOnOneChat,
isPolicyExpenseChat,
isSystemChat,
requiresAttentionFromCurrentUser,
} from '@libs/ReportUtils';
import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu';
import FreeTrial from '@pages/settings/Subscription/FreeTrial';
import variables from '@styles/variables';
Expand All @@ -47,13 +56,13 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
const {shouldUseNarrowLayout} = useResponsiveLayout();

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID || -1}`);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID}`);
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const session = useSession();
const shouldShowWokspaceChatTooltip = ReportUtils.isPolicyExpenseChat(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID;
const shouldShowWokspaceChatTooltip = isPolicyExpenseChat(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID;
const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+');
const shouldShowGetStartedTooltip = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report);
const shouldShowGetStartedTooltip = isOnboardingGuideAssigned ? isAdminRoom(report) : isConciergeChatReport(report);
const isActiveRouteHome = useIsCurrentRouteHome();

const {tooltipToRender, shouldShowTooltip} = useMemo(() => {
Expand All @@ -67,6 +76,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti

const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(tooltipToRender, shouldShowTooltip);

// During the onboarding flow, the introSelected NVP is not yet available.
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);

const {translate} = useLocalize();
const [isContextMenuActive, setIsContextMenuActive] = useState(false);

Expand Down Expand Up @@ -105,9 +117,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
}

const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
const shouldShowGreenDotIndicator = !hasBrickError && ReportUtils.requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction);
const shouldShowGreenDotIndicator = !hasBrickError && requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction);
const textStyle = isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText;
const textUnreadStyle = OptionsListUtils.shouldUseBoldText(optionItem) ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const textUnreadStyle = shouldUseBoldText(optionItem) ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const displayNameStyle = [styles.optionDisplayName, styles.optionDisplayNameCompact, styles.pre, textUnreadStyle, style];
const alternateTextStyle = isInFocusMode
? [textStyle, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2, style]
Expand Down Expand Up @@ -150,7 +162,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
const statusClearAfterDate = optionItem.status?.clearAfter ?? '';
const formattedDate = DateUtils.getStatusUntilDate(statusClearAfterDate);
const statusContent = formattedDate ? `${statusText ? `${statusText} ` : ''}(${formattedDate})` : statusText;
const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : undefined);
const isStatusVisible = !!emojiCode && isOneOnOneChat(!isEmptyObject(report) ? report : undefined);

const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar;
const firstIcon = optionItem.icons?.at(0);
Expand Down Expand Up @@ -245,7 +257,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
]}
shouldShowTooltip={OptionsListUtils.shouldOptionShowTooltip(optionItem)}
shouldShowTooltip={shouldOptionShowTooltip(optionItem)}
/>
))}
<View style={contentContainerStyles}>
Expand All @@ -264,11 +276,11 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
!!optionItem.isThread ||
!!optionItem.isMoneyRequestReport ||
!!optionItem.isInvoiceReport ||
ReportUtils.isGroupChat(report) ||
ReportUtils.isSystemChat(report)
isGroupChat(report) ||
isSystemChat(report)
}
/>
{ReportUtils.isChatUsedForOnboarding(report) && <FreeTrial badgeStyles={[styles.mnh0, styles.pl2, styles.pr2, styles.ml1]} />}
{isChatUsedForOnboarding(report, onboardingPurposeSelected) && <FreeTrial badgeStyles={[styles.mnh0, styles.pl2, styles.pr2, styles.ml1]} />}
{isStatusVisible && (
<Tooltip
text={statusContent}
Expand Down
15 changes: 11 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {FallbackAvatar, IntacctSquare, NetSuiteSquare, QBOSquare, XeroSquare} fr
import * as defaultGroupAvatars from '@components/Icon/GroupDefaultAvatars';
import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvatars';
import type {MoneyRequestAmountInputProps} from '@components/MoneyRequestAmountInput';
import type {IOUAction, IOUType} from '@src/CONST';
import type {IOUAction, IOUType, OnboardingPurpose} from '@src/CONST';
import CONST from '@src/CONST';
import type {ParentNavigationSummaryParams} from '@src/languages/params';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -8570,21 +8570,28 @@ function shouldShowMerchantColumn(transactions: Transaction[]) {
* DM, and we saved the report ID in the user's `onboarding` NVP. As a fallback for users who don't have the NVP, we now
* only use the Concierge chat.
*/
function isChatUsedForOnboarding(optionOrReport: OnyxEntry<Report> | OptionData): boolean {
function isChatUsedForOnboarding(optionOrReport: OnyxEntry<Report> | OptionData, onboardingPurposeSelected?: OnboardingPurpose): boolean {
// onboarding can be an empty object for old accounts and accounts created from olddot
if (onboarding && !isEmptyObject(onboarding) && onboarding.chatReportID) {
return onboarding.chatReportID === optionOrReport?.reportID;
}
if (isEmptyObject(onboarding)) {
return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport);
}

return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport);
// Onboarding guides are assigned to signups with emails that do not contain a '+' and select the "Manage my team's expenses" intent.
// Guides and onboarding tasks are posted to the #admins room to facilitate the onboarding process.
return onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+')
? isAdminRoom(optionOrReport)
: (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport);
}

/**
* Get the report used for the user's onboarding process. For most users it is the Concierge chat, however in the past
* we also used the system DM for A/B tests.
*/
function getChatUsedForOnboarding(): OnyxEntry<Report> {
return Object.values(allReports ?? {}).find(isChatUsedForOnboarding);
return Object.values(allReports ?? {}).find((report) => isChatUsedForOnboarding(report));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,

const isReportInRHP = route.name === SCREENS.SEARCH.REPORT_RHP;
const shouldDisplaySearchRouter = !isReportInRHP || isSmallScreenWidth;
const isChatUsedForOnboarding = isChatUsedForOnboardingReportUtils(report);
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
const isChatUsedForOnboarding = isChatUsedForOnboardingReportUtils(report, onboardingPurposeSelected);

return (
<View
Expand Down
Loading