Skip to content

fix: no sound when paying via QAB #61887

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
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 0 additions & 12 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import Permissions from '@libs/Permissions';
import {getDistanceRateCustomUnitRate, getTagLists, isTaxTrackingEnabled} from '@libs/PolicyUtils';
import {isSelectedManagerMcTest} from '@libs/ReportUtils';
import type {OptionData} from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import {
areRequiredFieldsEmpty,
calculateTaxAmount,
Expand Down Expand Up @@ -166,9 +165,6 @@ type MoneyRequestConfirmationListProps = {
/** The action to take */
action?: IOUAction;

/** Should play sound on confirmation */
shouldPlaySound?: boolean;

/** Whether the expense is confirmed or not */
isConfirmed?: boolean;

Expand Down Expand Up @@ -219,7 +215,6 @@ function MoneyRequestConfirmationList({
reportActionID,
action = CONST.IOU.ACTION.CREATE,
shouldDisplayReceipt = false,
shouldPlaySound = true,
isConfirmed,
isConfirming,
onPDFLoadError,
Expand Down Expand Up @@ -888,9 +883,6 @@ function MoneyRequestConfirmationList({
return;
}

if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}
onConfirm?.(selectedParticipants);
} else {
if (!paymentMethod) {
Expand All @@ -900,9 +892,6 @@ function MoneyRequestConfirmationList({
return;
}
Log.info(`[IOU] Sending money via: ${paymentMethod}`);
if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}
onSendMoney?.(paymentMethod);
}
},
Expand All @@ -924,7 +913,6 @@ function MoneyRequestConfirmationList({
isDistanceRequestWithPendingRoute,
iouAmount,
onConfirm,
shouldPlaySound,
transactionID,
reportID,
policy,
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ReceiptUploadRetryHandler/handleFileRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function handleFileRetry(message: ReceiptError, file: File, dismi
dismissError();
const startSplitBillParams = {...retryParams} as IOU.StartSplitBilActionParams;
startSplitBillParams.receipt = file;
startSplitBillParams.shouldPlaySound = false;
IOU.startSplitBill(startSplitBillParams);
break;
}
Expand All @@ -28,6 +29,7 @@ export default function handleFileRetry(message: ReceiptError, file: File, dismi
const trackExpenseParams = {...retryParams} as IOU.CreateTrackExpenseParams;
trackExpenseParams.transactionParams.receipt = file;
trackExpenseParams.isRetry = true;
trackExpenseParams.shouldPlaySound = false;
IOU.trackExpense(trackExpenseParams);
break;
}
Expand All @@ -36,6 +38,8 @@ export default function handleFileRetry(message: ReceiptError, file: File, dismi
const requestMoneyParams = {...retryParams} as IOU.RequestMoneyInformation;
requestMoneyParams.transactionParams.receipt = file;
requestMoneyParams.isRetry = true;
requestMoneyParams.shouldPlaySound = false;

IOU.requestMoney(requestMoneyParams);
break;
}
Expand Down
32 changes: 30 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
reimbursible?: boolean;
transactionParams: RequestMoneyTransactionParams;
isRetry?: boolean;
shouldPlaySound?: boolean;
backToReport?: string;
};

Expand Down Expand Up @@ -524,6 +525,7 @@
transactionParams: TrackExpenseTransactionParams;
accountantParams?: TrackExpenseAccountantParams;
isRetry?: boolean;
shouldPlaySound?: boolean;
};

type BuildOnyxDataForInvoiceParams = {
Expand Down Expand Up @@ -608,6 +610,7 @@
currency: string;
taxCode: string;
taxAmount: number;
shouldPlaySound?: boolean;
};

type ReplaceReceipt = {
Expand Down Expand Up @@ -4990,7 +4993,7 @@
* Submit expense to another user
*/
function requestMoney(requestMoneyInformation: RequestMoneyInformation) {
const {report, participantParams, policyParams = {}, transactionParams, gpsPoints, action, reimbursible, backToReport} = requestMoneyInformation;
const {report, participantParams, policyParams = {}, transactionParams, gpsPoints, action, reimbursible, backToReport, shouldPlaySound = true} = requestMoneyInformation;
const {payeeAccountID} = participantParams;
const parsedComment = getParsedComment(transactionParams.comment ?? '');
transactionParams.comment = parsedComment;
Expand Down Expand Up @@ -5067,6 +5070,10 @@
});
const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID;

if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}

switch (action) {
case CONST.IOU.ACTION.SUBMIT: {
if (!linkedTrackedExpenseReportAction || !linkedTrackedExpenseReportID) {
Expand Down Expand Up @@ -5240,6 +5247,8 @@
attendees: attendees ? JSON.stringify(attendees) : undefined,
};

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.CREATE_PER_DIEM_REQUEST, parameters, onyxData);

InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
Expand Down Expand Up @@ -5305,6 +5314,8 @@
...(invoiceChatReport?.reportID ? {receiverInvoiceRoomID: invoiceChatReport.reportID} : {receiverEmail: receiver.login ?? ''}),
};

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.SEND_INVOICE, parameters, onyxData);
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));

Expand All @@ -5321,7 +5332,7 @@
* Track an expense
*/
function trackExpense(params: CreateTrackExpenseParams) {
const {report, action, isDraftPolicy, participantParams, policyParams: policyData = {}, transactionParams: transactionData, accountantParams} = params;
const {report, action, isDraftPolicy, participantParams, policyParams: policyData = {}, transactionParams: transactionData, accountantParams, shouldPlaySound = true} = params;
const {participant, payeeAccountID, payeeEmail} = participantParams;
const {policy, policyCategories, policyTagList} = policyData;
const parsedComment = getParsedComment(transactionData.comment ?? '');
Expand Down Expand Up @@ -5444,6 +5455,9 @@
});

const mileageRate = isCustomUnitRateIDForP2P(transaction) ? undefined : customUnitRateID;
if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}

switch (action) {
case CONST.IOU.ACTION.CATEGORIZE: {
Expand Down Expand Up @@ -6177,6 +6191,8 @@
description: parsedComment,
};

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.SPLIT_BILL, parameters, onyxData);
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));

Expand Down Expand Up @@ -6251,6 +6267,8 @@
description: parsedComment,
};

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.SPLIT_BILL_AND_OPEN_REPORT, parameters, onyxData);
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));

Expand All @@ -6276,6 +6294,7 @@
currency,
taxCode = '',
taxAmount = 0,
shouldPlaySound = true,
}: StartSplitBilActionParams) {
const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin);
const participantAccountIDs = participants.map((participant) => Number(participant.accountID));
Expand Down Expand Up @@ -6590,6 +6609,9 @@
taxAmount,
description: parsedComment,
};
if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}

API.write(WRITE_COMMANDS.START_SPLIT_BILL, parameters, {optimisticData, successData, failureData});

Expand Down Expand Up @@ -6853,6 +6875,8 @@
description: parsedComment,
};

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.COMPLETE_SPLIT_BILL, parameters, {optimisticData, successData, failureData});
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
dismissModalAndOpenReportInInboxTab(chatReportID);
Expand Down Expand Up @@ -7040,6 +7064,8 @@
value: recentServerValidatedWaypoints,
});

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.CREATE_DISTANCE_REQUEST, parameters, onyxData);
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
const activeReportID = isMoneyRequestReport && report?.reportID ? report.reportID : parameters.chatReportID;
Expand Down Expand Up @@ -8205,7 +8231,7 @@

Object.values(iouReportActions).forEach((action) => {
const transactionID = isMoneyRequestAction(action) ? getOriginalMessage(action)?.IOUTransactionID : undefined;
const transaction = getTransaction(transactionID);

Check failure on line 8234 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx

if (transaction?.comment?.hold) {
holdReportActions.push(action as OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU>);
Expand Down Expand Up @@ -8772,6 +8798,7 @@
*/
function sendMoneyElsewhere(report: OnyxEntry<OnyxTypes.Report>, amount: number, currency: string, comment: string, managerID: number, recipient: Participant) {
const {params, optimisticData, successData, failureData} = getSendMoneyParams(report, amount, currency, comment, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, managerID, recipient);
playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.SEND_MONEY_ELSEWHERE, params, {optimisticData, successData, failureData});

Expand All @@ -8785,6 +8812,7 @@
*/
function sendMoneyWithWallet(report: OnyxEntry<OnyxTypes.Report>, amount: number, currency: string, comment: string, managerID: number, recipient: Participant | OptionData) {
const {params, optimisticData, successData, failureData} = getSendMoneyParams(report, amount, currency, comment, CONST.IOU.PAYMENT_TYPE.EXPENSIFY, managerID, recipient);
playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.SEND_MONEY_WITH_WALLET, params, {optimisticData, successData, failureData});

Expand Down
11 changes: 9 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import {
prepareOnboardingOnyxData,
} from '@libs/ReportUtils';
import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation';
import playSound, {SOUNDS} from '@libs/Sound';
import {addTrailingForwardSlash} from '@libs/Url';
import Visibility from '@libs/Visibility';
import CONFIG from '@src/CONFIG';
Expand Down Expand Up @@ -803,12 +804,18 @@ function addActions(reportID: string, text = '', file?: FileObject) {
}

/** Add an attachment and optional comment. */
function addAttachment(reportID: string, file: FileObject, text = '') {
function addAttachment(reportID: string, file: FileObject, text = '', shouldPlaySound?: boolean) {
if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}
addActions(reportID, text, file);
}

/** Add a single comment to a report */
function addComment(reportID: string, text: string) {
function addComment(reportID: string, text: string, shouldPlaySound?: boolean) {
if (shouldPlaySound) {
playSound(SOUNDS.DONE);
}
// If we are resolving a Concierge Category Options action on an expense report that only has a single transaction thread child report, we need to add the action to the transaction thread instead.
// This is because we need it to be associated with the transaction thread and not the expense report.
if (isExpenseReport(allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`])) {
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ function createTaskAndNavigate(
assigneeChatCreatedReportActionID: assigneeChatReportOnyxData?.optimisticChatCreatedReportAction?.reportActionID,
};

playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.CREATE_TASK, parameters, {optimisticData, successData, failureData});

if (!isCreatedUsingMarkdown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {getDraftComment} from '@libs/DraftCommentUtils';
import getModalState from '@libs/getModalState';
import Performance from '@libs/Performance';
import {canShowReportRecipientLocalTime, chatIncludesChronos, chatIncludesConcierge, getReportRecipientAccountIDs} from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside';
import ParticipantLocalTime from '@pages/home/report/ParticipantLocalTime';
import ReportDropUI from '@pages/home/report/ReportDropUI';
Expand Down Expand Up @@ -265,12 +264,10 @@ function ReportActionCompose({
*/
const submitForm = useCallback(
(newComment: string) => {
playSound(SOUNDS.DONE);

const newCommentTrimmed = newComment.trim();

if (attachmentFileRef.current) {
addAttachmentReportActions(reportID, attachmentFileRef.current, newCommentTrimmed);
addAttachmentReportActions(reportID, attachmentFileRef.current, newCommentTrimmed, true);
attachmentFileRef.current = null;
} else {
Performance.markStart(CONST.TIMING.SEND_MESSAGE, {message: newCommentTrimmed});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function ReportFooter({
if (isTaskCreated) {
return;
}
addComment(report.reportID, text);
addComment(report.reportID, text, true);
},
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[report.reportID, handleCreateTask],
Expand Down
4 changes: 0 additions & 4 deletions src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
import Performance from '@libs/Performance';
import {isPaidGroupPolicy} from '@libs/PolicyUtils';
import {getBankAccountRoute, getPolicyExpenseChat, getTransactionDetails, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {calculateTaxAmount, getAmount, getCurrency, getDefaultTaxCode, getRequestType, getTaxValue} from '@libs/TransactionUtils';
import MoneyRequestAmountForm from '@pages/iou/MoneyRequestAmountForm';
Expand Down Expand Up @@ -203,12 +202,10 @@ function IOURequestStepAmount({
sendMoneyWithWallet(report, backendAmount, currency, '', currentUserPersonalDetails.accountID, participants.at(0) ?? {});
return;
}

sendMoneyElsewhere(report, backendAmount, currency, '', currentUserPersonalDetails.accountID, participants.at(0) ?? {});
return;
}
if (iouType === CONST.IOU.TYPE.SUBMIT || iouType === CONST.IOU.TYPE.REQUEST) {
playSound(SOUNDS.DONE);
requestMoney({
report,
participantParams: {
Expand All @@ -228,7 +225,6 @@ function IOURequestStepAmount({
return;
}
if (iouType === CONST.IOU.TYPE.TRACK) {
playSound(SOUNDS.DONE);
trackExpense({
report,
isDraftPolicy: false,
Expand Down
2 changes: 0 additions & 2 deletions src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import {getDefaultCompanyWebsite} from '@libs/BankAccountUtils';
import {convertToDisplayString} from '@libs/CurrencyUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import {extractUrlDomain} from '@libs/Url';
import {getFieldRequiredErrors, isPublicDomain, isValidWebsite} from '@libs/ValidationUtils';
import Navigation from '@navigation/Navigation';
Expand Down Expand Up @@ -73,7 +72,6 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC

const submit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.MONEY_REQUEST_COMPANY_INFO_FORM>) => {
const companyWebsite = Str.sanitizeURL(values.companyWebsite, CONST.COMPANY_WEBSITE_DEFAULT_SCHEME);
playSound(SOUNDS.DONE);
sendInvoice(currentUserPersonalDetails.accountID, transaction, report, undefined, policy, policyTags, policyCategories, values.companyName, companyWebsite);
};

Expand Down
3 changes: 0 additions & 3 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import Navigation from '@libs/Navigation/Navigation';
import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
import Performance from '@libs/Performance';
import {generateReportID, getBankAccountRoute, getReportOrDraftReport, isProcessingReport, isReportOutstanding, isSelectedManagerMcTest} from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import {getDefaultTaxCode, getRateID, getRequestType, getValidWaypoints} from '@libs/TransactionUtils';
import ReceiptDropUI from '@pages/iou/ReceiptDropUI';
import type {GpsPoint} from '@userActions/IOU';
Expand Down Expand Up @@ -624,7 +623,6 @@ function IOURequestStepConfirmation({
}

formHasBeenSubmitted.current = true;
playSound(SOUNDS.DONE);

if (iouType !== CONST.IOU.TYPE.TRACK && isDistanceRequest && !isMovingTransactionFromTrackExpense) {
createDistanceRequest(iouType === CONST.IOU.TYPE.SPLIT ? splitParticipants : selectedParticipants, trimmedComment);
Expand Down Expand Up @@ -1017,7 +1015,6 @@ function IOURequestStepConfirmation({
shouldShowSmartScanFields={isMovingTransactionFromTrackExpense ? transaction?.amount !== 0 : requestType !== CONST.IOU.REQUEST_TYPE.SCAN}
action={action}
payeePersonalDetails={payeePersonalDetails}
shouldPlaySound={iouType === CONST.IOU.TYPE.PAY}
isConfirmed={isConfirmed}
isConfirming={isConfirming}
isReceiptEditable
Expand Down
3 changes: 0 additions & 3 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import Navigation from '@libs/Navigation/Navigation';
import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
import {getPersonalPolicy, getPolicy, isPaidGroupPolicy} from '@libs/PolicyUtils';
import {getPolicyExpenseChat, isArchivedReport, isPolicyExpenseChat as isPolicyExpenseChatUtil} from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {getDistanceInMeters, getRateID, getRequestType, getValidWaypoints, hasRoute, isCustomUnitRateIDForP2P} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -324,7 +323,6 @@ function IOURequestStepDistance({
setMoneyRequestMerchant(transactionID, translate('iou.fieldPending'), false);
const participant = participants.at(0);
if (iouType === CONST.IOU.TYPE.TRACK && participant) {
playSound(SOUNDS.DONE);
trackExpense({
report,
isDraftPolicy: false,
Expand All @@ -351,7 +349,6 @@ function IOURequestStepDistance({
return;
}

playSound(SOUNDS.DONE);
createDistanceRequest({
report,
participants,
Expand Down
Loading
Loading