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

fix: Tags - State field is not auto selected #52691

Merged
merged 1 commit into from
Nov 25, 2024
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
5 changes: 5 additions & 0 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function IOURequestStepConfirmation({
params: {iouType, reportID, transactionID, action, participantsAutoAssigned: participantsAutoAssignedFromRoute},
},
transaction,
isLoadingTransaction,
}: IOURequestStepConfirmationProps) {
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT;
Expand Down Expand Up @@ -603,6 +604,10 @@ function IOURequestStepConfirmation({
createTransaction(listOfParticipants);
};

if (isLoadingTransaction) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this code to withFullTransactionOrNotFound HOC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cannot guarantee that moving this code to the withFullTransactionOrNotFound HOC won't cause any issues. Therefore, I believe it's better to retain the current implementation within the scope of this issue.

return <FullScreenLoadingIndicator />;
}

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down
10 changes: 8 additions & 2 deletions src/pages/iou/request/step/withFullTransactionOrNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {Transaction} from '@src/types/onyx';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

type WithFullTransactionOrNotFoundOnyxProps = {
/** Indicates whether the report data is loading */
transaction: OnyxEntry<Transaction>;

/** Indicates whether the transaction data is loading */
isLoadingTransaction?: boolean;
};

type MoneyRequestRouteName =
Expand Down Expand Up @@ -54,8 +58,9 @@ export default function <TProps extends WithFullTransactionOrNotFoundProps<Money
const userAction = 'action' in route.params && route.params.action ? route.params.action : CONST.IOU.ACTION.CREATE;

const shouldUseTransactionDraft = IOUUtils.shouldUseTransactionDraft(userAction);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`);
const [transactionDraft] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`);
const [transaction, transactionResult] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`);
const [transactionDraft, transactionDraftResult] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`);
const isLoadingTransaction = isLoadingOnyxValue(transactionResult, transactionDraftResult);

const isFocused = useIsFocused();

Expand All @@ -70,6 +75,7 @@ export default function <TProps extends WithFullTransactionOrNotFoundProps<Money
// eslint-disable-next-line react/jsx-props-no-spreading
{...(props as TProps)}
transaction={shouldUseTransactionDraft ? transactionDraft : transaction}
isLoadingTransaction={isLoadingTransaction}
ref={ref}
/>
);
Expand Down
Loading