Skip to content

[CP Staging] Fixed submit button behavior in search #54012

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

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Mobile-Expensify
4 changes: 3 additions & 1 deletion src/components/SelectionList/Search/ActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type ActionCellProps = {
isChildListItem?: boolean;
parentAction?: string;
isLoading?: boolean;
isDisabled?: boolean;
};

function ActionCell({
Expand All @@ -43,6 +44,7 @@ function ActionCell({
isChildListItem = false,
parentAction = '',
isLoading = false,
isDisabled = false,
}: ActionCellProps) {
const {translate} = useLocalize();
const theme = useTheme();
Expand Down Expand Up @@ -113,7 +115,7 @@ function ActionCell({
innerStyles={getButtonInnerStyles(shouldUseSuccessStyleProp)}
isLoading={isLoading}
success={shouldUseSuccessStyleProp}
isDisabled={isOffline}
isDisabled={isOffline || isDisabled}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type ExpenseItemHeaderNarrowProps = {
isDisabledCheckbox?: boolean;
handleCheckboxPress?: () => void;
isLoading?: boolean;
isActionDisabled?: boolean;
};

function ExpenseItemHeaderNarrow({
Expand All @@ -48,6 +49,7 @@ function ExpenseItemHeaderNarrow({
handleCheckboxPress,
text,
isLoading = false,
isActionDisabled = false,
}: ExpenseItemHeaderNarrowProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -108,6 +110,7 @@ function ExpenseItemHeaderNarrow({
isLargeScreenWidth={false}
isSelected={isSelected}
isLoading={isLoading}
isDisabled={isActionDisabled}
/>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import DateUtils from '@libs/DateUtils';
import {getFileName} from '@libs/fileDownload/FileUtils';
import Parser from '@libs/Parser';
import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils';
import * as ReportUtils from '@libs/ReportUtils';
import StringUtils from '@libs/StringUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot';
Expand Down Expand Up @@ -266,6 +267,10 @@ function TransactionListItemRow({
const theme = useTheme();

const isOnHold = useMemo(() => TransactionUtils.isOnHold(item), [item]);
const shouldDisableItemAction = useMemo(
() => item.action === CONST.SEARCH.ACTION_TYPES.SUBMIT && !ReportUtils.isAllowedToSubmitDraftExpenseReport(ReportUtils.getReport(item.reportID)),
Copy link
Contributor

Choose a reason for hiding this comment

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

This line might fail since the Search data is contained within the snapshot_ key and ReportUtils.getReport will try to look for data in the report_ key

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to pass the snapshot data to it

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened a new PR here that changes the behavior to show View instead of submit #54056

[item],
);

if (!isLargeScreenWidth) {
return (
Expand All @@ -286,6 +291,7 @@ function TransactionListItemRow({
isDisabledCheckbox={item.isDisabledCheckbox}
handleCheckboxPress={onCheckboxPress}
isLoading={isLoading}
isActionDisabled={shouldDisableItemAction}
/>
)}

Expand Down Expand Up @@ -453,6 +459,7 @@ function TransactionListItemRow({
parentAction={parentAction}
goToItem={onButtonPress}
isLoading={isLoading}
isDisabled={shouldDisableItemAction}
/>
</View>
</View>
Expand Down
Loading