Repository navigation
[HOLD] Show and action Bill Pay reports in New Expensify #102113
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
Open
cead22
wants to merge
15
commits into
main
Choose a base branch
from
carlos-billpay
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4873eb4
Show and action Bill Pay reports in New Expensify
cead22 f4ec3bd
Reuse Classic bill create and payment commands
cead22 b86b6d7
Remove Bill Pay contributing guide
cead22 a1b9b81
Derive the bill receiver from its report owner
cead22 c543cca
Hide bill payment actions when workspace payments are disabled
cead22 fbac287
Fix manual bill creation payload and cover bill actions
cead22 c951788
Read bill and invoice links from report name value pairs
cead22 8d33325
Hide Reject on bills because Auth can't reject them
cead22 4d59fb3
Name the vendor when a bill payment waits for a bank account
cead22 1e0115f
Show the payment action on bills and invoices paid from NewDot
cead22 0444926
Show a bill To its current approver and filter Bills Approve by it
cead22 6b13a9f
Let the payer pay a canceled bill on a workspace with approvals turne…
cead22 e0b3eff
Link a bill's subtitle to its owner's workspace chat
cead22 aa0e98b
Merge remote-tracking branch 'origin/main' into carlos-billpay
cead22 3ef284d
Show settlement columns in Bills search
cead22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /** Pays bills and received invoices without depending on a parent room. */ | ||
|
|
||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
|
|
||
| import {payBill} from '@libs/actions/BillPay'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {Report} from '@src/types/onyx'; | ||
| import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; | ||
|
|
||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| import ButtonWithDropdownMenu from './ButtonWithDropdownMenu'; | ||
| import {useDelegateNoAccessActions, useDelegateNoAccessState} from './DelegateNoAccessModalProvider'; | ||
| import {useLockedAccountActions, useLockedAccountState} from './LockedAccountModalProvider'; | ||
| import OfflineWithFeedback from './OfflineWithFeedback'; | ||
| import {useSearchQueryContext} from './Search/SearchContext'; | ||
|
|
||
| type BillPaymentButtonProps = { | ||
| report: OnyxEntry<Report>; | ||
| isDisabled?: boolean; | ||
| searchHash?: number; | ||
| }; | ||
|
|
||
| function BillPaymentButton({report, isDisabled = false, searchHash}: BillPaymentButtonProps) { | ||
| const {currentSearchKey} = useSearchQueryContext(); | ||
| const {translate} = useLocalize(); | ||
| const icons = useMemoizedLazyExpensifyIcons(['Bank', 'Cash']); | ||
| const [bankAccounts] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); | ||
| const {isAccountLocked} = useLockedAccountState(); | ||
| const {showLockedAccountModal} = useLockedAccountActions(); | ||
| const {isDelegateAccessRestricted} = useDelegateNoAccessState(); | ||
| const {showDelegateNoAccessModal} = useDelegateNoAccessActions(); | ||
| const pay = (paymentMethod: PaymentMethodType, bankAccountID?: number) => { | ||
| if (isAccountLocked) { | ||
| showLockedAccountModal(); | ||
| return; | ||
| } | ||
| if (isDelegateAccessRestricted) { | ||
| showDelegateNoAccessModal(); | ||
| return; | ||
| } | ||
| payBill(report, paymentMethod, bankAccountID, searchHash, currentSearchKey); | ||
| }; | ||
| const bankOptions = Object.values(bankAccounts ?? {}) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI: Offers accessible, open USD debit accounts and excludes card-settlement accounts. Slack clarifies that payment admins may use any bank account they can access, not only the workspace account. Context: Bank access clarification. |
||
| .filter( | ||
| (bank) => | ||
| bank.accountData?.allowDebit && | ||
| bank.accountData.state === CONST.BANK_ACCOUNT.STATE.OPEN && | ||
| bank.bankCurrency === CONST.CURRENCY.USD && | ||
| !bank.isExpensifyCardSettlementAccount, | ||
| ) | ||
| .map((bank) => ({ | ||
| text: bank.title ?? bank.description ?? '', | ||
| description: bank.description, | ||
| icon: icons.Bank, | ||
| onSelected: () => pay(CONST.IOU.PAYMENT_TYPE.EXPENSIFY, bank.accountData?.bankAccountID ?? bank.methodID), | ||
| })); | ||
|
|
||
| return ( | ||
| <OfflineWithFeedback | ||
| errors={report?.errorFields?.reimbursed} | ||
| pendingAction={report?.pendingFields?.reimbursed} | ||
| > | ||
| <ButtonWithDropdownMenu | ||
| customText={translate('iou.pay')} | ||
| variant={CONST.BUTTON_VARIANT.SUCCESS} | ||
| isSplitButton={false} | ||
| shouldAlwaysShowDropdownMenu | ||
| isDisabled={isDisabled || !!report?.pendingFields?.reimbursed} | ||
| isLoading={!!report?.pendingFields?.reimbursed} | ||
| onPress={() => {}} | ||
| options={[ | ||
| { | ||
| text: translate('billPay.payByACH'), | ||
| value: CONST.IOU.PAYMENT_TYPE.EXPENSIFY, | ||
| icon: icons.Bank, | ||
| disabled: report?.currency !== CONST.CURRENCY.USD, | ||
| subMenuItems: [ | ||
| ...bankOptions, | ||
| { | ||
| text: translate('bankAccount.addBankAccount'), | ||
| icon: icons.Bank, | ||
| onSelected: () => | ||
| Navigation.navigate( | ||
| report?.type === CONST.REPORT.TYPE.BILL && report.policyID | ||
| ? ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute({policyID: report.policyID}) | ||
| : ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(), | ||
| ), | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| text: translate('billPay.markAsPaid'), | ||
| value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, | ||
| icon: icons.Cash, | ||
| onSelected: () => pay(CONST.IOU.PAYMENT_TYPE.ELSEWHERE), | ||
| }, | ||
| ]} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| ); | ||
| } | ||
|
|
||
| export default BillPaymentButton; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI: Adds a shared ACH/Mark as paid menu for bills and invoices. It uses the report directly, so payment does not depend on a parent room.
Context: Approval and payment requirements, No parent room requirement.