Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/libs/ExpensifyCardFeedSelectorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ function hasConfiguredExpensifyCardFeed(settings: ExpensifyCardSettings | undefi
continue;
}
if (programKey === CONST.TRAVEL.PROGRAM_TRAVEL_US) {
// Linking a disabled travel feed doesn't turn it back on, so it goes through the enable flow.
if (nested.isEnabled === false) {
continue;
Comment on lines +50 to +51

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep invoice-only disabled feeds reactivatable

When a pay-by-invoice feed has invoiceTo but no paymentBankAccountID, turning it off sets isEnabled to false and this branch removes it from accessibleTravelFeeds. The fallback in WorkspaceTravelBillingSection.continueToggleFlow then treats it as lacking a settlement account and routes to WorkspaceTravelBillingSettlementAccountPage, whose only activation path calls configureTravelBillingForPolicy with a selected bank account. As a result, invoice-only customers cannot turn Consolidated Travel Billing back on without adding or switching to an ACH account, so this disabled state needs an invoice-capable re-enable path rather than being unconditionally filtered out.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

a pay-by-invoice feed with no bank account gets removed when it's turned off, and turning it on needs a verified bank account anyway, so the settlement account page is right here

}
if (hasTravelBillingSettlementAccount(nested) || getIsTravelBillingPayByInvoice(nested)) {
return true;
}
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/ExpensifyCardFeedSelectorUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ describe('getAdminExpensifyCardFeedEntries', () => {
expect(currentEntries.map((entry) => entry.fundID)).toEqual([feedFundID]);
});

it('hides a travel feed that was turned off', () => {
// Given a travel feed that keeps its settlement account after Consolidated Travel Billing is turned off
const travelSettings = (isEnabled: boolean): OnyxCollection<ExpensifyCardSettings> => ({
[`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${feedFundID}`]: {
[CONST.TRAVEL.PROGRAM_TRAVEL_US]: {paymentBankAccountID: 23242, isEnabled},
},
});

// When the travel feeds are listed for the off and on states
const disabledEntries = getAdminExpensifyCardFeedEntries(travelSettings(false), adminPolicyForFund, {}, currentUserAccountID, [CONST.TRAVEL.PROGRAM_TRAVEL_US]);
const enabledEntries = getAdminExpensifyCardFeedEntries(travelSettings(true), adminPolicyForFund, {}, currentUserAccountID, [CONST.TRAVEL.PROGRAM_TRAVEL_US]);

// Then only the enabled feed is offered, because linking a disabled one would leave the toggle off
expect(disabledEntries).toHaveLength(0);
expect(enabledEntries.map((entry) => entry.fundID)).toEqual([feedFundID]);
});

it('hides a feed when the user is neither a domain admin nor a workspace admin for the fund', () => {
const nonAdminPolicy = createPolicyCollection([createAdminPolicy({id: workspacePolicyID, policyAccountID: 9999})]);

Expand Down
Loading